Commit 49418b2c28c901294f8b36ff14c766c9458c3623

Authored by Eric W. Biederman
1 parent dbfb98af18

cifs: Modify struct cifs_unix_set_info_args to hold a kuid_t and a kgid_t

Use INVALID_UID and INVALID_GID instead of NO_CHANGE_64 to indicate
the value should not be changed.

In cifs_fill_unix_set_info convert from kuids and kgids into uids and
gids that will fit in FILE_UNIX_BASIC_INFO.

Cc: Steve French <smfrench@gmail.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Showing 5 changed files with 28 additions and 22 deletions Side-by-side Diff

... ... @@ -305,8 +305,8 @@
305 305 __u64 atime;
306 306 __u64 mtime;
307 307 __u64 mode;
308   - __u64 uid;
309   - __u64 gid;
  308 + kuid_t uid;
  309 + kgid_t gid;
310 310 dev_t device;
311 311 };
312 312  
... ... @@ -5819,8 +5819,14 @@
5819 5819 cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
5820 5820 const struct cifs_unix_set_info_args *args)
5821 5821 {
  5822 + u64 uid = NO_CHANGE_64, gid = NO_CHANGE_64;
5822 5823 u64 mode = args->mode;
5823 5824  
  5825 + if (uid_valid(args->uid))
  5826 + uid = from_kuid(&init_user_ns, args->uid);
  5827 + if (gid_valid(args->gid))
  5828 + gid = from_kgid(&init_user_ns, args->gid);
  5829 +
5824 5830 /*
5825 5831 * Samba server ignores set of file size to zero due to bugs in some
5826 5832 * older clients, but we should be precise - we use SetFileSize to
... ... @@ -5833,8 +5839,8 @@
5833 5839 data_offset->LastStatusChange = cpu_to_le64(args->ctime);
5834 5840 data_offset->LastAccessTime = cpu_to_le64(args->atime);
5835 5841 data_offset->LastModificationTime = cpu_to_le64(args->mtime);
5836   - data_offset->Uid = cpu_to_le64(args->uid);
5837   - data_offset->Gid = cpu_to_le64(args->gid);
  5842 + data_offset->Uid = cpu_to_le64(uid);
  5843 + data_offset->Gid = cpu_to_le64(gid);
5838 5844 /* better to leave device as zero when it is */
5839 5845 data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
5840 5846 data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
... ... @@ -342,14 +342,14 @@
342 342  
343 343 *created |= FILE_CREATED;
344 344 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
345   - args.uid = (__u64) current_fsuid();
  345 + args.uid = current_fsuid();
346 346 if (inode->i_mode & S_ISGID)
347   - args.gid = (__u64) inode->i_gid;
  347 + args.gid = inode->i_gid;
348 348 else
349   - args.gid = (__u64) current_fsgid();
  349 + args.gid = current_fsgid();
350 350 } else {
351   - args.uid = NO_CHANGE_64;
352   - args.gid = NO_CHANGE_64;
  351 + args.uid = INVALID_UID; /* no change */
  352 + args.gid = INVALID_GID; /* no change */
353 353 }
354 354 CIFSSMBUnixSetFileInfo(xid, tcon, &args, fid->netfid,
355 355 current->tgid);
356 356  
... ... @@ -588,11 +588,11 @@
588 588 .device = device_number,
589 589 };
590 590 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
591   - args.uid = (__u64) current_fsuid();
592   - args.gid = (__u64) current_fsgid();
  591 + args.uid = current_fsuid();
  592 + args.gid = current_fsgid();
593 593 } else {
594   - args.uid = NO_CHANGE_64;
595   - args.gid = NO_CHANGE_64;
  594 + args.uid = INVALID_UID; /* no change */
  595 + args.gid = INVALID_GID; /* no change */
596 596 }
597 597 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
598 598 cifs_sb->local_nls,
... ... @@ -487,8 +487,8 @@
487 487 */
488 488 struct cifs_unix_set_info_args args = {
489 489 .mode = inode->i_mode,
490   - .uid = NO_CHANGE_64,
491   - .gid = NO_CHANGE_64,
  490 + .uid = INVALID_UID, /* no change */
  491 + .gid = INVALID_GID, /* no change */
492 492 .ctime = NO_CHANGE_64,
493 493 .atime = NO_CHANGE_64,
494 494 .mtime = NO_CHANGE_64,
... ... @@ -1249,14 +1249,14 @@
1249 1249 .device = 0,
1250 1250 };
1251 1251 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
1252   - args.uid = (__u64)current_fsuid();
  1252 + args.uid = current_fsuid();
1253 1253 if (parent->i_mode & S_ISGID)
1254   - args.gid = (__u64)parent->i_gid;
  1254 + args.gid = parent->i_gid;
1255 1255 else
1256   - args.gid = (__u64)current_fsgid();
  1256 + args.gid = current_fsgid();
1257 1257 } else {
1258   - args.uid = NO_CHANGE_64;
1259   - args.gid = NO_CHANGE_64;
  1258 + args.uid = INVALID_UID; /* no change */
  1259 + args.gid = INVALID_GID; /* no change */
1260 1260 }
1261 1261 CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
1262 1262 cifs_sb->local_nls,
1263 1263  
... ... @@ -2017,12 +2017,12 @@
2017 2017 if (attrs->ia_valid & ATTR_UID)
2018 2018 args->uid = attrs->ia_uid;
2019 2019 else
2020   - args->uid = NO_CHANGE_64;
  2020 + args->uid = INVALID_UID; /* no change */
2021 2021  
2022 2022 if (attrs->ia_valid & ATTR_GID)
2023 2023 args->gid = attrs->ia_gid;
2024 2024 else
2025   - args->gid = NO_CHANGE_64;
  2025 + args->gid = INVALID_GID; /* no change */
2026 2026  
2027 2027 if (attrs->ia_valid & ATTR_ATIME)
2028 2028 args->atime = cifs_UnixTimeToNT(attrs->ia_atime);