From: Eric W. Biederman Date: Wed, 6 Feb 2013 07:55:44 +0000 (-0800) Subject: cifs: Override unmappable incoming uids and gids X-Git-Tag: Ubuntu-snapdragon-4.4.0-1029.32~11479^2~12 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=46bbc25f9ff1242cd1c042580aec11ddb5e41369;p=mirror_ubuntu-zesty-kernel.git cifs: Override unmappable incoming uids and gids The cifs protocol has a 64bit space for uids and gids, while linux only supports a 32bit space today. Instead of silently truncating 64bit cifs ids, replace cifs ids that do not fit in the 32bit linux id space with the default uid and gids for the cifs mount. Cc: Steve French Signed-off-by: "Eric W. Biederman" --- diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ed6208ff85a7..d7ea2a6eaead 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -244,15 +244,19 @@ cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info, break; } - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) - fattr->cf_uid = cifs_sb->mnt_uid; - else - fattr->cf_uid = le64_to_cpu(info->Uid); - - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) - fattr->cf_gid = cifs_sb->mnt_gid; - else - fattr->cf_gid = le64_to_cpu(info->Gid); + fattr->cf_uid = cifs_sb->mnt_uid; + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)) { + u64 id = le64_to_cpu(info->Uid); + if (id < ((uid_t)-1)) + fattr->cf_uid = id; + } + + fattr->cf_gid = cifs_sb->mnt_gid; + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)) { + u64 id = le64_to_cpu(info->Gid); + if (id < ((gid_t)-1)) + fattr->cf_gid = id; + } fattr->cf_nlink = le64_to_cpu(info->Nlinks); }