From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8493C47080 for ; Mon, 31 May 2021 17:34:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B452F60231 for ; Mon, 31 May 2021 17:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232190AbhEaRgh (ORCPT ); Mon, 31 May 2021 13:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbhEaRga (ORCPT ); Mon, 31 May 2021 13:36:30 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D6AC014CE0 for ; Mon, 31 May 2021 09:40:39 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnkxw-0030gH-Fw; Mon, 31 May 2021 16:40:36 +0000 Date: Mon, 31 May 2021 16:40:36 +0000 From: Al Viro To: tianyu zhou Cc: linux-fsdevel@vger.kernel.org Subject: Re: Missing check for CAP_SYS_ADMIN in do_reconfigure_mnt() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, May 31, 2021 at 10:59:54PM +0800, tianyu zhou wrote: > Hi, function do_remount() in fs/namespace.c checks the CAP_SYS_ADMIN > before it calls set_mount_attributes(). > > -------------------- > // fs/namespace.c > static int do_remount(struct path *path, int ms_flags, int sb_flags, > int mnt_flags, void *data) > { > .... > if (ns_capable(sb->s_user_ns, CAP_SYS_ADMIN)) { > err = reconfigure_super(fc); > if (!err) { > lock_mount_hash(); > set_mount_attributes(mnt, mnt_flags); // <=== > protected function > unlock_mount_hash(); > } > ... > } > -------------------- > > However, in another caller of set_mount_attributes(), > do_reconfigure_mnt(), I have not found any check for CAP_SYS_ADMIN. > So, is there a missing check bug inside do_reconfigure_mnt() ? (which > makes it possible for normal user to reach set_mount_attributes()) IDGI. By the same token, there are callers of e.g. memcpy() with CAP_SYS_ADMIN checks upstream of those, as well as those that are called without any such checks whatsoever. The answer to such observation would obviously be "what of that?" and I really wonder what your criteria are. For another example, in the same function you have lock_mount_hash() calls as well; are you going to report the calls of that made without CAP_SYS_ADMIN? IOW, what are the heuristics you are using to select the functions you deem suspicious?