Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5928246ybv; Tue, 18 Feb 2020 06:38:34 -0800 (PST) X-Google-Smtp-Source: APXvYqw0uQOhcfDluU2MlPAEt09MmHPvlBwmUy6mzuwqHCMzaPwQLu/srQHx2skKD6sLIReiIlkK X-Received: by 2002:a9d:10d:: with SMTP id 13mr3499120otu.238.1582036714090; Tue, 18 Feb 2020 06:38:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582036714; cv=none; d=google.com; s=arc-20160816; b=fZrCP8mhftV61yEYLNp67aNdKuZ2u2V+ounZU8hny4Qp/xNYs79SJl15nk6UAj6CWH V7TBsQyf4C8wQRfqv7sDgx22wu8I7YPWkoH8ZD5PZpaIp8Iydk2IRKB9BG3O6V0A1GZK kop3K/XckLoAMvgNlhVr+t6+N4hP3KoDn4DX6O2kT5p5CKGcl+/xAGHywUIoNfwAp/Br xKspXK/3SHebBEqvtAPzZ/Yv3aGmUe3Jh94f7QGV9RtbfpDhMRh7mLsLP82tuCBgIiZN 2T40m7I2fEIlD5/6lepXKdiqBGz1mJD7/tqTCm0x1RH8sMh4BosujVfyLLD/TQVuXbtz 45FQ== 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=OaczyrWtvlFZ0K/koXIh62csOZW8xx8d2fQOaLYLJ9M=; b=tFEZRNZcnReuMOk2pLZ3CRUiPAQOTdjjO8m227xGRNChSHGjOfuIvNhwhAlriyCOVn h93Cfi3BGQUCKDNxIgykV1WLrH7dwRd/gvvtm2ir6q4EmdJyG6spPfWEqki79QUPh4yd 2Gy1h17JOrqkprj0oBuNP0Az7/tTSsTGiVE5LHXCbLlpYkam93XaN4XQJVlYI4Jodm9y 2Ju+wI2+DPZik5t6BQzlgl5PDif6yrmOB1wd2knlnbNJXVB0Q10lTfwovRKXTIGlOTWP rSW1aEZSqBxMPzVu7hMXyEUWUJZc6LeagQV6te0v4PTNWmZgd0c3JD8trIJDdQIswIdk FlcQ== 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 l83si7896732oih.58.2020.02.18.06.38.21; Tue, 18 Feb 2020 06:38:34 -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 S1727918AbgBROg7 (ORCPT + 99 others); Tue, 18 Feb 2020 09:36:59 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:53142 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726620AbgBROg5 (ORCPT ); Tue, 18 Feb 2020 09:36:57 -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 1j43yB-0000fF-Br; Tue, 18 Feb 2020 14:35:27 +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 22/25] devpts: handle fsid mappings Date: Tue, 18 Feb 2020 15:34:08 +0100 Message-Id: <20200218143411.2389182-23-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 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 /* v3 */ 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