Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2061317ybv; Fri, 14 Feb 2020 10:41:30 -0800 (PST) X-Google-Smtp-Source: APXvYqzaQa12OqrB/mTPRBQ5U9/UFS6cHd/k87/HJpojRiYMsWYDd/XU+gJ3F99Mg+NZLyoiJBA9 X-Received: by 2002:aca:d954:: with SMTP id q81mr2803873oig.157.1581705690800; Fri, 14 Feb 2020 10:41:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581705690; cv=none; d=google.com; s=arc-20160816; b=it9Z5fprsjU9HPE55Kll6jQaasEw5gJ8r7EGKn/nUS6JY4w0+2tTEXz0tbDh15Ko2X Qw+j5XNof+YU0Stu3PlorVA9Y8wJAiHe2e1W41UnFp9Tj3tmb7xCKP0xrjJMCFRsEvha 6wGonFuK8YxwLBRBjtiVHM6ffl/Z5qe43B1A6Vwq8jJ1e7j96dB0J4Xs2nhz6L6ApzWz rTvqxQUmfl5bQSN5+iM8Mp4z9wBIhPLu9PfsEfNOgcLVIr3joIYVx1UMmvvUNqE3RpFG 6R1SsLPNz6mftUpSVEN2Py0VaFlFRFRrknic2N7v0v6fmDFi/lEdaUYxXzzJuxLpXMui uKYw== 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=tqoFFNsDqLo0cu7TxrjWYAmVF1MW8AJYit8HqS7l8Eo=; b=C/Dy/56ya67DX+o0p+i11hRO7Ll0SEbuwoBmePhxw9Ot6RVfAywgg/hHdNzbjayQUp aR10HWLQToR6Si3heDnVNd/t72WIwGqsC/PBPPsdK4Q0x9pQhgFyVLTKYtNPMqrkzn7S OmmUC/yGtIxHvRJlL2YnU6Aq6Pi93TNlJwc3Cf9MlmOGR0RNlEHCZKmJkub0KYa0Z+8H RRDWs5AIuUKAM/LtazJpM7VEV3w1uSJXZh2swOjIP3kCl14UbB5Ha24y1gazHtETu7M/ 8BTQ+Ktcl1BZ0ADPEeZwWlzvkN0+pYxOySpLKH1fBIkgZZfhnwooBIkwA76zCEpqExih wUKg== 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 e15si3531606otq.237.2020.02.14.10.41.18; Fri, 14 Feb 2020 10:41:30 -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 S2389140AbgBNSlN (ORCPT + 99 others); Fri, 14 Feb 2020 13:41:13 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:33859 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388668AbgBNSlM (ORCPT ); Fri, 14 Feb 2020 13:41:12 -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 1j2fqi-0000uO-7i; Fri, 14 Feb 2020 18:38:00 +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 21/28] posix_acl: handle fsid mappings Date: Fri, 14 Feb 2020 19:35:47 +0100 Message-Id: <20200214183554.1133805-22-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 Switch posix_acls() to lookup fsids in the fsid mappings. If no fsid mappings are setup the behavior is unchanged, i.e. fsids are looked up in the id mappings. Afaict, all filesystems that share a superblock in all user namespaces currently do not support acls so this change should be safe to do unconditionally. Signed-off-by: Christian Brauner --- /* v2 */ unchanged --- fs/posix_acl.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 249672bf54fe..763bba24f380 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -22,6 +22,7 @@ #include #include #include +#include static struct posix_acl **acl_by_type(struct inode *inode, int type) { @@ -692,12 +693,12 @@ static void posix_acl_fix_xattr_userns( for (end = entry + count; entry != end; entry++) { switch(le16_to_cpu(entry->e_tag)) { case ACL_USER: - uid = make_kuid(from, le32_to_cpu(entry->e_id)); - entry->e_id = cpu_to_le32(from_kuid(to, uid)); + uid = make_kfsuid(from, le32_to_cpu(entry->e_id)); + entry->e_id = cpu_to_le32(from_kfsuid(to, uid)); break; case ACL_GROUP: - gid = make_kgid(from, le32_to_cpu(entry->e_id)); - entry->e_id = cpu_to_le32(from_kgid(to, gid)); + gid = make_kfsgid(from, le32_to_cpu(entry->e_id)); + entry->e_id = cpu_to_le32(from_kfsgid(to, gid)); break; default: break; @@ -746,12 +747,12 @@ posix_acl_from_xattr(struct user_namespace *user_ns, return ERR_PTR(-EINVAL); if (count == 0) return NULL; - + acl = posix_acl_alloc(count, GFP_NOFS); if (!acl) return ERR_PTR(-ENOMEM); acl_e = acl->a_entries; - + for (end = entry + count; entry != end; acl_e++, entry++) { acl_e->e_tag = le16_to_cpu(entry->e_tag); acl_e->e_perm = le16_to_cpu(entry->e_perm); @@ -765,14 +766,14 @@ posix_acl_from_xattr(struct user_namespace *user_ns, case ACL_USER: acl_e->e_uid = - make_kuid(user_ns, + make_kfsuid(user_ns, le32_to_cpu(entry->e_id)); if (!uid_valid(acl_e->e_uid)) goto fail; break; case ACL_GROUP: acl_e->e_gid = - make_kgid(user_ns, + make_kfsgid(user_ns, le32_to_cpu(entry->e_id)); if (!gid_valid(acl_e->e_gid)) goto fail; @@ -817,11 +818,11 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, switch(acl_e->e_tag) { case ACL_USER: ext_entry->e_id = - cpu_to_le32(from_kuid(user_ns, acl_e->e_uid)); + cpu_to_le32(from_kfsuid(user_ns, acl_e->e_uid)); break; case ACL_GROUP: ext_entry->e_id = - cpu_to_le32(from_kgid(user_ns, acl_e->e_gid)); + cpu_to_le32(from_kfsgid(user_ns, acl_e->e_gid)); break; default: ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID); -- 2.25.0