Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2060299ybv; Fri, 14 Feb 2020 10:40:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwsEnwEMn2uE3PX0NAa/ELyHTHPpIs7PBRPOJOw0e9PMS5IB5w+wFmhro+tATNr+U0ARF4J X-Received: by 2002:a9d:53c4:: with SMTP id i4mr3600198oth.48.1581705620293; Fri, 14 Feb 2020 10:40:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581705620; cv=none; d=google.com; s=arc-20160816; b=JMMbM+jb9q5LLa18PMWoDWvuz8hozJPEKgEEXUU6dbXm5CoMgUwZPXky1+5dFD4LMt QOQYTdrMjDhyBswO188IvGq8SpYuA8KhUUVgtm03tb4zZLZMyu4ty9XM5i3aT5dIdokx 3esKRpj606BD8uBKN0/zcY5oIGo6zvHYuKk84FA27xjTVzSY2JpqOyQIaKMAw+euwcdy jrOy2kItID8vXgqYIs3g+zZg45au+uzTo5WRpzxhr1fzfgruK3829qjTF/OaGBcZsyP8 X/7StgKl6gkjC9o0W8iDQY7udRbd50Q/hx1c0fhUAT755EK/IW95Bh06f/P7Pwp1w8qm y0ag== 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=Ky5a5KvRUPA1BqNiPLvIaUgZtIDhuCMzqntcWFA7VrM=; b=p/9hbBxJot5zNk6nXL0jWQdasyiqE1qsqnKXWBrGHsD5N17XJl0cqpmsaiqpPf1+pD pqVwfkpl56f2CXRZfZ3qetFTc5VI1Q6xi98eSqZAgOfibYjD+/9dHFCtTc7fMDbSJr/7 6v+Pw6cc9SkgXN61EzqB4o5vOZOGcmnutITt9RWb0uxG//A7rhyHYX0Ue5sZcDNgjP8F LWb4CngOdRRGYChkXllqezv7xfwEv7JgHYzaL8bVPb8rSdETuivyBA8pYtv+w4A9yXdn LZJRRx+1I7mS51E2IO2o1zpdlXsPg8WHsED85qrsT1LEyyVl+DZi4Ne/2sZ3vr8MDyhR Q5Fw== 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 e25si3512631otk.62.2020.02.14.10.40.07; Fri, 14 Feb 2020 10:40:20 -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 S1730803AbgBNSkD (ORCPT + 99 others); Fri, 14 Feb 2020 13:40:03 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:33798 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729781AbgBNSkB (ORCPT ); Fri, 14 Feb 2020 13:40:01 -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 1j2fqp-0000uO-PK; Fri, 14 Feb 2020 18:38: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 v2 28/28] devpts: handle fsid mappings Date: Fri, 14 Feb 2020 19:35:54 +0100 Message-Id: <20200214183554.1133805-29-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200214183554.1133805-1-christian.brauner@ubuntu.com> References: <20200214183554.1133805-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 When a uid or gid mount option is specified with devpts have it lookup the corresponding kfsids in the fsid mappings. If no fsid mappings are setup the behavior is unchanged, i.e. fsids are looked up in the id mappings. Signed-off-by: Christian Brauner --- /* v2 */ unchanged --- fs/devpts/inode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 42e5a766d33c..139958892572 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -24,6 +24,7 @@ #include #include #include +#include #define DEVPTS_DEFAULT_MODE 0600 /* @@ -277,7 +278,7 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) case Opt_uid: if (match_int(&args[0], &option)) return -EINVAL; - uid = make_kuid(current_user_ns(), option); + uid = make_kfsuid(current_user_ns(), option); if (!uid_valid(uid)) return -EINVAL; opts->uid = uid; @@ -286,7 +287,7 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) case Opt_gid: if (match_int(&args[0], &option)) return -EINVAL; - gid = make_kgid(current_user_ns(), option); + gid = make_kfsgid(current_user_ns(), option); if (!gid_valid(gid)) return -EINVAL; opts->gid = gid; @@ -410,7 +411,7 @@ static int devpts_show_options(struct seq_file *seq, struct dentry *root) from_kuid_munged(&init_user_ns, opts->uid)); if (opts->setgid) seq_printf(seq, ",gid=%u", - from_kgid_munged(&init_user_ns, opts->gid)); + from_kfsgid_munged(&init_user_ns, opts->gid)); seq_printf(seq, ",mode=%03o", opts->mode); seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode); if (opts->max < NR_UNIX98_PTY_MAX) -- 2.25.0