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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 9F527C47082 for ; Mon, 31 May 2021 17:44:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E6DA611CA for ; Mon, 31 May 2021 17:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233319AbhEaRp5 (ORCPT ); Mon, 31 May 2021 13:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231826AbhEaRpo (ORCPT ); Mon, 31 May 2021 13:45:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4D9C06129E for ; Mon, 31 May 2021 10:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hhjNHtVotsrkCPgVTalYOAJUNqMIrZxU+HqjLpfTXkk=; b=EaiRQfavcMyCeRQ7c+8BCxLfB5 k32YJySHXy3bYKmuUwvh67a+j5E0j2o92UJ49QokxJ3AnKu6vXS/wmVJchTaJauKFl0autTkw4CZO 3UXSy2wGFJ5GwBm0H2/pkBWf5E+HsKTeE3Lfh6EQcnHut6+TIR03dLRqQMB9+hGOdJjnKeqrKt8XG iAZpwY3wXZTk3Eo9UI1uMEwS9UFC9uhwVmPR2vuLPrwjfVssxn1Ir7MfVY5W9PmlnENGxDN+LnOSF xr/l2eiRshfvIv6rQKhYdgc+EePPLFOF7ftLJjIC1sdsdCv8h0rqBcpZXgzmheEc0PhOivhbuxB2w rHc1MLew==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lnlNc-009FBO-2M; Mon, 31 May 2021 17:07:12 +0000 Date: Mon, 31 May 2021 18:07:08 +0100 From: Matthew Wilcox To: tianyu zhou Cc: Alexander Viro , 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: 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(). > > 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()) You weren't looking hard enough ... path_mount() if (!may_mount()) return -EPERM; ... if ((flags & (MS_REMOUNT | MS_BIND)) == (MS_REMOUNT | MS_BIND)) return do_reconfigure_mnt(path, mnt_flags); (this is the only call to do_reconfigure_mnt()) and: static inline bool may_mount(void) { return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN); }