Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5927368ybv; Tue, 18 Feb 2020 06:37:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzGJMC5wArwsZkd4T/qs/QuCg/UjsYNFqUGQfj674jCwcQjKYTFDfM7rLopyBe2+Tq79wqT X-Received: by 2002:aca:4ace:: with SMTP id x197mr1476563oia.23.1582036657089; Tue, 18 Feb 2020 06:37:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582036657; cv=none; d=google.com; s=arc-20160816; b=jlnPYZxy65LNdSuCiA7QvCou2WY6nIikcA+1QISptcnL7Rc8ubnupeisqqit6UdmQl QpkesF3UNbfRlaNTcyIfSwJsa9qx93hbIiHgAk/wr8vAT8usuFQfLDLiajYOIjolhOu4 E7PfRCzNHFKNFxC4EDwtbV3ev9tHfu5oFuZkRJbULfDpIfPoelY7eSt/eq7yedTwrNxH LXwLT1M5E6X+vYLeYS8UfGFRrF2JCwytYhS+pZLKw2SylvW4n5ZToL2VAyTn1QdQV0pE du9e9PcVfaz5pM4lB4zIjkw06S5ATxfxrvgxAEJH9sZ38tYQgNt0RrWcjthP9EHfCjht 86nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yKnkd8g3RUzliXYI+dXRDWzp7rAoaxFkyMlkyXoghnI=; b=vE0q0EXKQuhIQ0ikrlitGCh9RTDIf66hfwmTlyYZ29vlhfdIH4uLWQk6MKecRa6ypo kGZ2aIrCzw1zJSfkFbOegaxIQhxrLmnYvLeUwpXwv9AWFE1jfxWkX2lhceIl6sAOAEgk o28qt4EvE8lseE4AT247Acbpm7T+2VUqVAO+GYMLUdQu9+lywf+KCLMs1qKG14Yb0P+U t3+eDVvv/Zr+vB0V6Ul1MbL348upzadRigJZvc8jNpu7hUwyIo1tXMiyYlhnkz8VunXQ DTgmpIuZ72IX/QTojWpdkV0qfCgxxq0rvefKa7caPF8t8sC58pOjo6syGDj39As3hYmm T3KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d83si7857750oib.166.2020.02.18.06.37.25; Tue, 18 Feb 2020 06:37:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727890AbgBROgv (ORCPT + 99 others); Tue, 18 Feb 2020 09:36:51 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52971 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbgBROff (ORCPT ); Tue, 18 Feb 2020 09:35:35 -0500 Received: from ip5f5bf7ec.dynamic.kabel-deutschland.de ([95.91.247.236] helo=wittgenstein.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j43xr-0000fF-7O; Tue, 18 Feb 2020 14:35:07 +0000 From: Christian Brauner To: =?UTF-8?q?St=C3=A9phane=20Graber?= , "Eric W. Biederman" , Aleksa Sarai , Jann Horn Cc: smbarber@chromium.org, Seth Forshee , Alexander Viro , Alexey Dobriyan , Serge Hallyn , James Morris , Kees Cook , Jonathan Corbet , Phil Estes , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, Christian Brauner Subject: [PATCH v3 03/25] proc: add /proc//fsgid_map Date: Tue, 18 Feb 2020 15:33:49 +0100 Message-Id: <20200218143411.2389182-4-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200218143411.2389182-1-christian.brauner@ubuntu.com> References: <20200218143411.2389182-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The /proc//fsgid_map file can be written once to setup an fsgid mapping for a user namespace. Writing to this file has the same restrictions as writing to /proc//fsgid_map. root@e1-vm:/# cat /proc/13023/fsgid_map 0 300000 100000 Fsid mappings have always been around. They are currently always identical to the id mappings for a user namespace. This means, currently whenever an fsid needs to be looked up the kernel will use the id mapping of the user namespace. With the introduction of fsid mappings the kernel will now lookup fsids in the fsid mappings of the user namespace. If no fsid mapping exists the kernel will continue looking up fsids in the id mappings of the user namespace. Hence, if a system supports fsid mappings through /proc//fs*id_map and a container runtime is not aware of fsid mappings it or does not use them it will it will continue to work just as before. Signed-off-by: Christian Brauner --- /* v2 */ unchanged /* v3 */ - Christian Brauner : - Fix grammar in commit message. --- fs/proc/base.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index 5fb28004663e..1303cdd2e617 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2975,6 +2975,11 @@ static int proc_fsuid_map_open(struct inode *inode, struct file *file) { return proc_id_map_open(inode, file, &proc_fsuid_seq_operations); } + +static int proc_fsgid_map_open(struct inode *inode, struct file *file) +{ + return proc_id_map_open(inode, file, &proc_fsgid_seq_operations); +} #endif static const struct file_operations proc_uid_map_operations = { @@ -3009,6 +3014,14 @@ static const struct file_operations proc_fsuid_map_operations = { .llseek = seq_lseek, .release = proc_id_map_release, }; + +static const struct file_operations proc_fsgid_map_operations = { + .open = proc_fsgid_map_open, + .write = proc_fsgid_map_write, + .read = seq_read, + .llseek = seq_lseek, + .release = proc_id_map_release, +}; #endif static int proc_setgroups_open(struct inode *inode, struct file *file) @@ -3195,6 +3208,7 @@ static const struct pid_entry tgid_base_stuff[] = { #ifdef CONFIG_USER_NS #ifdef CONFIG_USER_NS_FSID REG("fsuid_map", S_IRUGO|S_IWUSR, proc_fsuid_map_operations), + REG("fsgid_map", S_IRUGO|S_IWUSR, proc_fsgid_map_operations), #endif REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations), REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations), -- 2.25.0