mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Fix ACL checks for NFS kernel server
This PR changes ZFS ACL checks to evaluate fsuid / fsgid rather than euid / egid to avoid accidentally granting elevated permissions to NFS clients. Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Andrew Walker <awalker@ixsystems.com> Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org> Closes #13221
This commit is contained in:
@@ -1653,8 +1653,10 @@ zfs_acl_ids_create(znode_t *dzp, int flag, vattr_t *vap, cred_t *cr,
|
||||
ZFS_GROUP, &acl_ids->z_fuidp);
|
||||
gid = vap->va_gid;
|
||||
} else {
|
||||
acl_ids->z_fuid = zfs_fuid_create_cred(zfsvfs, ZFS_OWNER,
|
||||
cr, &acl_ids->z_fuidp);
|
||||
uid_t id = crgetuid(cr);
|
||||
if (IS_EPHEMERAL(id))
|
||||
id = UID_NOBODY;
|
||||
acl_ids->z_fuid = (uint64_t)id;
|
||||
acl_ids->z_fgid = 0;
|
||||
if (vap->va_mask & AT_GID) {
|
||||
acl_ids->z_fgid = zfs_fuid_create(zfsvfs,
|
||||
|
||||
@@ -1043,8 +1043,7 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode,
|
||||
objset_t *os;
|
||||
dmu_tx_t *tx;
|
||||
int error;
|
||||
ksid_t *ksid;
|
||||
uid_t uid;
|
||||
uid_t uid = crgetuid(cr);
|
||||
gid_t gid = crgetgid(cr);
|
||||
uint64_t projid = ZFS_DEFAULT_PROJID;
|
||||
zfs_acl_ids_t acl_ids;
|
||||
@@ -1058,13 +1057,6 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode,
|
||||
* If we have an ephemeral id, ACL, or XVATTR then
|
||||
* make sure file system is at proper version
|
||||
*/
|
||||
|
||||
ksid = crgetsid(cr, KSID_OWNER);
|
||||
if (ksid)
|
||||
uid = ksid_getid(ksid);
|
||||
else
|
||||
uid = crgetuid(cr);
|
||||
|
||||
if (zfsvfs->z_use_fuids == B_FALSE &&
|
||||
(vsecp || (vap->va_mask & AT_XVATTR) ||
|
||||
IS_EPHEMERAL(uid) || IS_EPHEMERAL(gid)))
|
||||
@@ -1396,8 +1388,7 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp,
|
||||
uint64_t txtype;
|
||||
dmu_tx_t *tx;
|
||||
int error;
|
||||
ksid_t *ksid;
|
||||
uid_t uid;
|
||||
uid_t uid = crgetuid(cr);
|
||||
gid_t gid = crgetgid(cr);
|
||||
zfs_acl_ids_t acl_ids;
|
||||
boolean_t fuid_dirtied;
|
||||
@@ -1408,12 +1399,6 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp,
|
||||
* If we have an ephemeral id, ACL, or XVATTR then
|
||||
* make sure file system is at proper version
|
||||
*/
|
||||
|
||||
ksid = crgetsid(cr, KSID_OWNER);
|
||||
if (ksid)
|
||||
uid = ksid_getid(ksid);
|
||||
else
|
||||
uid = crgetuid(cr);
|
||||
if (zfsvfs->z_use_fuids == B_FALSE &&
|
||||
((vap->va_mask & AT_XVATTR) ||
|
||||
IS_EPHEMERAL(uid) || IS_EPHEMERAL(gid)))
|
||||
|
||||
Reference in New Issue
Block a user