-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
Remove duplicate z_uid/z_gid member which are also held in the generic vfs inode struct. This is done by first removing the members from struct znode and then using the KUID_TO_SUID/KGID_TO_SGID macros to access the respective member from struct inode. In cases where the uid/gids are being marshalled from/to disk, use the newly introduced zfs_(uid|gid)_(read|write) functions to properly save the uids rather than the internal kernel representation. Signed-off-by: Nikolay Borisov <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#4685 Issue openzfs#227
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
#define _TRACE_ACL_H | ||
|
||
#include <linux/tracepoint.h> | ||
#include <linux/vfs_compat.h> | ||
#include <sys/types.h> | ||
|
||
/* | ||
|
@@ -56,15 +57,15 @@ DECLARE_EVENT_CLASS(zfs_ace_class, | |
__field(uint64_t, z_mapcnt) | ||
__field(uint64_t, z_size) | ||
__field(uint64_t, z_pflags) | ||
__field(uint64_t, z_uid) | ||
__field(uint64_t, z_gid) | ||
__field(uint32_t, z_sync_cnt) | ||
__field(mode_t, z_mode) | ||
__field(boolean_t, z_is_sa) | ||
__field(boolean_t, z_is_mapped) | ||
__field(boolean_t, z_is_ctldir) | ||
__field(boolean_t, z_is_stale) | ||
|
||
__field(uint32_t, i_uid) | ||
__field(uint32_t, i_gid) | ||
__field(unsigned long, i_ino) | ||
__field(unsigned int, i_nlink) | ||
__field(u64, i_version) | ||
|
@@ -91,15 +92,15 @@ DECLARE_EVENT_CLASS(zfs_ace_class, | |
__entry->z_mapcnt = zn->z_mapcnt; | ||
__entry->z_size = zn->z_size; | ||
__entry->z_pflags = zn->z_pflags; | ||
__entry->z_uid = zn->z_uid; | ||
__entry->z_gid = zn->z_gid; | ||
__entry->z_sync_cnt = zn->z_sync_cnt; | ||
__entry->z_mode = zn->z_mode; | ||
__entry->z_is_sa = zn->z_is_sa; | ||
__entry->z_is_mapped = zn->z_is_mapped; | ||
__entry->z_is_ctldir = zn->z_is_ctldir; | ||
__entry->z_is_stale = zn->z_is_stale; | ||
|
||
__entry->i_uid = zfs_uid_read(ZTOI(zn)); | ||
__entry->i_gid = zfs_gid_read(ZTOI(zn)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lorddoskias
|
||
__entry->i_ino = zn->z_inode.i_ino; | ||
__entry->i_nlink = zn->z_inode.i_nlink; | ||
__entry->i_version = zn->z_inode.i_version; | ||
|
@@ -118,22 +119,22 @@ DECLARE_EVENT_CLASS(zfs_ace_class, | |
TP_printk("zn { id %llu unlinked %u atime_dirty %u " | ||
"zn_prefetch %u moved %u blksz %u seq %u " | ||
"mapcnt %llu size %llu pflags %llu " | ||
"uid %llu gid %llu sync_cnt %u mode 0x%x is_sa %d " | ||
"sync_cnt %u mode 0x%x is_sa %d " | ||
"is_mapped %d is_ctldir %d is_stale %d inode { " | ||
"ino %lu nlink %u version %llu size %lli blkbits %u " | ||
"bytes %u mode 0x%x generation %x } } ace { type %u " | ||
"flags %u access_mask %u } mask_matched %u", | ||
"uid %u gid %u ino %lu nlink %u version %llu size %lli " | ||
"blkbits %u bytes %u mode 0x%x generation %x } } " | ||
"ace { type %u flags %u access_mask %u } mask_matched %u", | ||
__entry->z_id, __entry->z_unlinked, __entry->z_atime_dirty, | ||
__entry->z_zn_prefetch, __entry->z_moved, __entry->z_blksz, | ||
__entry->z_seq, __entry->z_mapcnt, __entry->z_size, | ||
__entry->z_pflags, __entry->z_uid, | ||
__entry->z_gid, __entry->z_sync_cnt, __entry->z_mode, | ||
__entry->z_pflags, __entry->z_sync_cnt, __entry->z_mode, | ||
__entry->z_is_sa, __entry->z_is_mapped, | ||
__entry->z_is_ctldir, __entry->z_is_stale, __entry->i_ino, | ||
__entry->i_nlink, __entry->i_version, __entry->i_size, | ||
__entry->i_blkbits, __entry->i_bytes, __entry->i_mode, | ||
__entry->i_generation, __entry->z_type, __entry->z_flags, | ||
__entry->z_access_mask, __entry->mask_matched) | ||
__entry->z_is_ctldir, __entry->z_is_stale, __entry->i_uid, | ||
__entry->i_gid, __entry->i_ino, __entry->i_nlink, | ||
__entry->i_version, __entry->i_size, __entry->i_blkbits, | ||
__entry->i_bytes, __entry->i_mode, __entry->i_generation, | ||
__entry->z_type, __entry->z_flags, __entry->z_access_mask, | ||
__entry->mask_matched) | ||
); | ||
|
||
#define DEFINE_ACE_EVENT(name) \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -602,6 +602,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) | |
int count = 0; | ||
sa_bulk_attr_t bulk[4]; | ||
uint64_t mtime[2], ctime[2]; | ||
uint32_t uid; | ||
ASSERTV(int iovcnt = uio->uio_iovcnt); | ||
|
||
/* | ||
|
@@ -862,11 +863,12 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) | |
* user 0 is not an ephemeral uid. | ||
*/ | ||
mutex_enter(&zp->z_acl_lock); | ||
uid = KUID_TO_SUID(ip->i_uid); | ||
if ((zp->z_mode & (S_IXUSR | (S_IXUSR >> 3) | | ||
(S_IXUSR >> 6))) != 0 && | ||
(zp->z_mode & (S_ISUID | S_ISGID)) != 0 && | ||
secpolicy_vnode_setid_retain(cr, | ||
(zp->z_mode & S_ISUID) != 0 && zp->z_uid == 0) != 0) { | ||
((zp->z_mode & S_ISUID) != 0 && uid == 0)) != 0) { | ||
uint64_t newmode; | ||
zp->z_mode &= ~(S_ISUID | S_ISGID); | ||
newmode = zp->z_mode; | ||
|
@@ -2844,7 +2846,7 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) | |
if (mask & ATTR_UID) { | ||
new_uid = zfs_fuid_create(zsb, | ||
(uint64_t)vap->va_uid, cr, ZFS_OWNER, &fuidp); | ||
if (new_uid != zp->z_uid && | ||
if (new_uid != KUID_TO_SUID(ZTOI(zp)->i_uid) && | ||
zfs_fuid_overquota(zsb, B_FALSE, new_uid)) { | ||
if (attrzp) | ||
iput(ZTOI(attrzp)); | ||
|
@@ -2856,7 +2858,7 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) | |
if (mask & ATTR_GID) { | ||
new_gid = zfs_fuid_create(zsb, (uint64_t)vap->va_gid, | ||
cr, ZFS_GROUP, &fuidp); | ||
if (new_gid != zp->z_gid && | ||
if (new_gid != KGID_TO_SGID(ZTOI(zp)->i_gid) && | ||
zfs_fuid_overquota(zsb, B_TRUE, new_gid)) { | ||
if (attrzp) | ||
iput(ZTOI(attrzp)); | ||
|
@@ -2950,24 +2952,24 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) | |
if (mask & ATTR_UID) { | ||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zsb), NULL, | ||
&new_uid, sizeof (new_uid)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lorddoskias
|
||
zp->z_uid = new_uid; | ||
ZTOI(zp)->i_uid = SUID_TO_KUID(new_uid); | ||
if (attrzp) { | ||
SA_ADD_BULK_ATTR(xattr_bulk, xattr_count, | ||
SA_ZPL_UID(zsb), NULL, &new_uid, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
sizeof (new_uid)); | ||
attrzp->z_uid = new_uid; | ||
ZTOI(attrzp)->i_uid = SUID_TO_KUID(new_uid); | ||
} | ||
} | ||
|
||
if (mask & ATTR_GID) { | ||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zsb), | ||
NULL, &new_gid, sizeof (new_gid)); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
zp->z_gid = new_gid; | ||
ZTOI(zp)->i_gid = SGID_TO_KGID(new_gid); | ||
if (attrzp) { | ||
SA_ADD_BULK_ATTR(xattr_bulk, xattr_count, | ||
SA_ZPL_GID(zsb), NULL, &new_gid, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
sizeof (new_gid)); | ||
attrzp->z_gid = new_gid; | ||
ZTOI(attrzp)->i_gid = SGID_TO_KGID(new_gid); | ||
} | ||
} | ||
if (!(mask & ATTR_MODE)) { | ||
|
@@ -3847,7 +3849,7 @@ zfs_link(struct inode *tdip, struct inode *sip, char *name, cred_t *cr, | |
return (SET_ERROR(EINVAL)); | ||
} | ||
|
||
owner = zfs_fuid_map_id(zsb, szp->z_uid, cr, ZFS_OWNER); | ||
owner = zfs_fuid_map_id(zsb, KUID_TO_SUID(sip->i_uid), cr, ZFS_OWNER); | ||
if (owner != crgetuid(cr) && secpolicy_basic_link(cr) != 0) { | ||
ZFS_EXIT(zsb); | ||
return (SET_ERROR(EPERM)); | ||
|
@lorddoskias
use KUID