Commit f0bb29d5 authored by Christian Brauner's avatar Christian Brauner Committed by Steve French

ksmbd: fix subauth 0 handling in sid_to_id()

It's not obvious why subauth 0 would be excluded from translation. This
would lead to wrong results whenever a non-identity idmapping is used.

Cc: Steve French <stfrench@microsoft.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Namjae Jeon <namjae.jeon@samsung.com>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 0e844efe
...@@ -274,7 +274,7 @@ static int sid_to_id(struct user_namespace *user_ns, ...@@ -274,7 +274,7 @@ static int sid_to_id(struct user_namespace *user_ns,
uid_t id; uid_t id;
id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]); id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
if (id > 0) { if (id >= 0) {
uid = make_kuid(user_ns, id); uid = make_kuid(user_ns, id);
if (uid_valid(uid) && kuid_has_mapping(user_ns, uid)) { if (uid_valid(uid) && kuid_has_mapping(user_ns, uid)) {
fattr->cf_uid = uid; fattr->cf_uid = uid;
...@@ -286,7 +286,7 @@ static int sid_to_id(struct user_namespace *user_ns, ...@@ -286,7 +286,7 @@ static int sid_to_id(struct user_namespace *user_ns,
gid_t id; gid_t id;
id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]); id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
if (id > 0) { if (id >= 0) {
gid = make_kgid(user_ns, id); gid = make_kgid(user_ns, id);
if (gid_valid(gid) && kgid_has_mapping(user_ns, gid)) { if (gid_valid(gid) && kgid_has_mapping(user_ns, gid)) {
fattr->cf_gid = gid; fattr->cf_gid = gid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment