From patchwork Wed Jan 25 15:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 48193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp345839wrn; Wed, 25 Jan 2023 07:53:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXu2HakUSlmyXp3DOENiXsZr1mdZ8GFXzLD8Dg4YdnLpcy3w3h2Ox9kX1Y6tXWjWLXwN3+Uf X-Received: by 2002:a17:90b:2347:b0:228:f6d0:f14d with SMTP id ms7-20020a17090b234700b00228f6d0f14dmr33485955pjb.32.1674662033812; Wed, 25 Jan 2023 07:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674662033; cv=none; d=google.com; s=arc-20160816; b=L4+9hoEfYqlAWCTcqUFAyBfxOztCWwpRvT3ZtzqgtJiXXDuLqBgh0DW10DoW/IWZjr bFrFjo9OjDj+iKC5PXS6kVyIeeesZTem4BZBtwj68gLrYp4R5RBwkfU6oO80eqGMk8tb Rxr9crVszWJTyj4JWKxHmStKpS+5aZgC7gpF8cQzL7VRpcuLvLygYy0bs1AaOpfYecdQ xcZtk9mdRcHKNrJTNHSQaN+pu6pWcx1LJlB6n/JySakZW4l/MsYLvtdekJ6kasaEtwYl hTUSDke3XpapuRJg/QdFgT2bQGGU/WjRxrjzh8ridAaa3ijizzpitnAItsK2ZVsIhyUR JwGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=X8i+2xAs+1XX7enWEvraFZH/M50c7zPbVr8UsbUZJmE=; b=nbVCYdw2N/Taa0zckSK6HQoOZH34COR/CN5no7O8oV8nRaEOQsApk+kF7pZQot8zqq K7FwhM88dwI2MPRoOD2Kf35zdk3VPrZ6dBmMFQX284quRE4y9tpauTlzx5EBB/orVKy+ udiXe6GcjyrbV6hVSFbZU/RwNlAbK+/t1t8I8Ayqcu95ziTESPI4I4BfBn2iE1649KN+ y3eU0my28lw/+3a+WnFuKaXrqHzUyRZsKZ7RVM9QbeIoUomJaMsunVJVy1Rmpq6OMiEC s6KHXn7d7oAdXK8xXIAlMQLfRnhQsmI0Rb7mGAect0xu0lmkSallTw/gOHuBCG0LpWIJ md/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a17090a4ec500b002298cb34320si2565051pjl.116.2023.01.25.07.53.42; Wed, 25 Jan 2023 07:53:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjAYPuT (ORCPT + 99 others); Wed, 25 Jan 2023 10:50:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234845AbjAYPuS (ORCPT ); Wed, 25 Jan 2023 10:50:18 -0500 X-Greylist: delayed 1232 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 25 Jan 2023 07:50:17 PST Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11FF75867F for ; Wed, 25 Jan 2023 07:50:16 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-LG1apAgMNhCnHMZXWZtq6A-1; Wed, 25 Jan 2023 10:29:34 -0500 X-MC-Unique: LG1apAgMNhCnHMZXWZtq6A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 73EAC85C6E2; Wed, 25 Jan 2023 15:29:33 +0000 (UTC) Received: from comp-core-i7-2640m-0182e6.redhat.com (ovpn-208-16.brq.redhat.com [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id B32BE2026D4B; Wed, 25 Jan 2023 15:29:31 +0000 (UTC) From: Alexey Gladkov To: LKML , containers@lists.linux.dev, linux-fsdevel@vger.kernel.org Cc: Alexey Dobriyan , Al Viro , Andrew Morton , Christian Brauner , Val Cowan Subject: [RFC PATCH v1 4/6] proc: Allow to use the allowlist filter in userns Date: Wed, 25 Jan 2023 16:28:51 +0100 Message-Id: <76e8b2d0c0651af6906351b7d43fa2a4d117dc04.1674660533.git.legion@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RDNS_NONE,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756010416818037673?= X-GMAIL-MSGID: =?utf-8?q?1756010416818037673?= Signed-off-by: Alexey Gladkov --- fs/proc/proc_allowlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/proc_allowlist.c b/fs/proc/proc_allowlist.c index 2153acb8e467..c605f73622bd 100644 --- a/fs/proc/proc_allowlist.c +++ b/fs/proc/proc_allowlist.c @@ -100,7 +100,7 @@ static int open_allowlist(struct inode *inode, struct file *file) struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb); int ret; - if (!capable(CAP_SYS_ADMIN)) + if (!ns_capable(current_user_ns(), CAP_SYS_ADMIN)) return -EPERM; // we need this because shrink_dcache_sb() can't drop our own dentry. @@ -199,7 +199,7 @@ static const struct proc_ops proc_allowlist_ops = { static int __init proc_allowlist_init(void) { struct proc_dir_entry *pde; - pde = proc_create("allowlist", S_IRUSR | S_IWUSR, NULL, &proc_allowlist_ops); + pde = proc_create("allowlist", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, NULL, &proc_allowlist_ops); pde_make_permanent(pde); pde_make_allowlist(pde); return 0;