Skip to content

Commit

Permalink
ksmbd: add supplementary group support
Browse files Browse the repository at this point in the history
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Sep 24, 2024
1 parent fd01fc4 commit deec9ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ksmbd_netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ struct ksmbd_login_response {
__u16 hash_sz; /* hash size */
__s8 hash[KSMBD_REQ_MAX_HASH_SZ]; /* password hash */
__u32 reserved[16]; /* Reserved room */
__u32 ngroup;
__u32 gid[];
};

/*
Expand Down
17 changes: 16 additions & 1 deletion smb_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ int __ksmbd_override_fsids(struct ksmbd_work *work,
struct group_info *gi;
unsigned int uid;
unsigned int gid;
int i;

uid = user_uid(sess->user);
gid = user_gid(sess->user);
Expand All @@ -800,11 +801,25 @@ int __ksmbd_override_fsids(struct ksmbd_work *work,
cred->fsuid = make_kuid(&init_user_ns, uid);
cred->fsgid = make_kgid(&init_user_ns, gid);

gi = groups_alloc(0);
gi = groups_alloc(share->ngroups);
if (!gi) {
abort_creds(cred);
return -ENOMEM;
}

if (share->ngroups <= NGROUPS_MAX) {
for (i = 0; i < share->ngroups; i++) {
if (gid_eq(GLOBAL_ROOT_GID,
make_kgid(&init_user_ns, share->gid[i])))
gi->gid[i] = cred->fsgid;
else
gi->gid[i] = make_kgid(&init_user_ns,
share->gid[i]);
}

groups_sort(gi);
}

set_groups(cred, gi);
put_group_info(gi);

Expand Down

0 comments on commit deec9ef

Please sign in to comment.