Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sunrpc: Properly encode kuids and kgids in RPC_AUTH_UNIX credentials

When writing kuids onto the wire first map them into the initial user
namespace.

When writing kgids onto the wire first map them into the initial user
namespace.

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+3 -3
+3 -3
net/sunrpc/auth_unix.c
··· 157 157 */ 158 158 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); 159 159 160 - *p++ = htonl((u32) cred->uc_uid); 161 - *p++ = htonl((u32) cred->uc_gid); 160 + *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid)); 161 + *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid)); 162 162 hold = p++; 163 163 for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++) 164 - *p++ = htonl((u32) cred->uc_gids[i]); 164 + *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i])); 165 165 *hold = htonl(p - hold - 1); /* gid array length */ 166 166 *base = htonl((p - base - 1) << 2); /* cred length */ 167 167