Skip to content

Commit d051026

Browse files
committed
Revert parts of 938cfeb
When read and writing the UID/GID, we always want the value relative to the root user namespace, the kernel will take care of remapping this to the user namespace for us. Calling from_kuid(user_ns, uid) with a unmapped uid will return -1 as that uid is outside of the scope of that namespace, and will result in the files inside the namespace all being owned by 'nobody' and not being allowed to call chmod or chown on them. Signed-off-by: Allan Jude <allan@klarasystems.com>
1 parent ded851b commit d051026

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

include/os/linux/kernel/linux/vfs_compat.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ static inline struct dentry *file_dentry(const struct file *f)
296296

297297
static inline uid_t zfs_uid_read_impl(struct inode *ip)
298298
{
299-
#ifdef HAVE_SUPER_USER_NS
300-
return (from_kuid(ip->i_sb->s_user_ns, ip->i_uid));
301-
#else
302299
return (from_kuid(kcred->user_ns, ip->i_uid));
303-
#endif
304300
}
305301

306302
static inline uid_t zfs_uid_read(struct inode *ip)
@@ -310,11 +306,7 @@ static inline uid_t zfs_uid_read(struct inode *ip)
310306

311307
static inline gid_t zfs_gid_read_impl(struct inode *ip)
312308
{
313-
#ifdef HAVE_SUPER_USER_NS
314-
return (from_kgid(ip->i_sb->s_user_ns, ip->i_gid));
315-
#else
316309
return (from_kgid(kcred->user_ns, ip->i_gid));
317-
#endif
318310
}
319311

320312
static inline gid_t zfs_gid_read(struct inode *ip)
@@ -324,20 +316,12 @@ static inline gid_t zfs_gid_read(struct inode *ip)
324316

325317
static inline void zfs_uid_write(struct inode *ip, uid_t uid)
326318
{
327-
#ifdef HAVE_SUPER_USER_NS
328-
ip->i_uid = make_kuid(ip->i_sb->s_user_ns, uid);
329-
#else
330319
ip->i_uid = make_kuid(kcred->user_ns, uid);
331-
#endif
332320
}
333321

334322
static inline void zfs_gid_write(struct inode *ip, gid_t gid)
335323
{
336-
#ifdef HAVE_SUPER_USER_NS
337-
ip->i_gid = make_kgid(ip->i_sb->s_user_ns, gid);
338-
#else
339324
ip->i_gid = make_kgid(kcred->user_ns, gid);
340-
#endif
341325
}
342326

343327
/*

0 commit comments

Comments
 (0)