From de35ac0d1efe1ffc415d6407795afe6cea473495 Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Wed, 3 Nov 2021 08:03:08 -0400 Subject: [PATCH] Make zpl_permission work with 5.12+ kernels The "permission" inode operation takes a new `struct user_namespace *` parameter starting in Linux 5.12. Add a configure check and adapt accordingly. Signed-off-by: Ryan Moeller --- include/os/linux/zfs/sys/zpl.h | 5 +++++ module/os/linux/zfs/zpl_xattr.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index afea2336ba..55cdf51c97 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -106,7 +106,12 @@ zpl_chmod_acl(struct inode *ip) } #endif /* CONFIG_FS_POSIX_ACL */ +#if defined(HAVE_IOPS_PERMISSION_USERNS) +extern int zpl_permission(struct user_namespace *userns, struct inode *ip, + int mask); +#else extern int zpl_permission(struct inode *ip, int mask); +#endif extern xattr_handler_t *zpl_xattr_handlers[]; diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 332dc63970..11f07dbb5b 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1483,7 +1483,11 @@ static xattr_handler_t zpl_xattr_acl_default_handler = { #endif /* CONFIG_FS_POSIX_ACL */ int +#if defined(HAVE_IOPS_PERMISSION_USERNS) +zpl_permission(struct user_namespace *userns, struct inode *ip, int mask) +#else zpl_permission(struct inode *ip, int mask) +#endif { int to_check = 0, i, ret; cred_t *cr = NULL; @@ -1496,7 +1500,11 @@ zpl_permission(struct inode *ip, int mask) */ if ((ITOZSB(ip)->z_acl_type != ZFS_ACLTYPE_NFSV4) || ((ITOZ(ip)->z_pflags & ZFS_ACL_TRIVIAL && GENERIC_MASK(mask)))) { +#if defined(HAVE_IOPS_PERMISSION_USERNS) + return (generic_permission(userns, ip, mask)); +#else return (generic_permission(ip, mask)); +#endif } for (i = 0; i < ARRAY_SIZE(mask2zfs); i++) { @@ -1510,7 +1518,11 @@ zpl_permission(struct inode *ip, int mask) * NFSv4 ACE. Pass back to default kernel permissions check. */ if (to_check == 0) { +#if defined(HAVE_IOPS_PERMISSION_USERNS) + return (generic_permission(userns, ip, mask)); +#else return (generic_permission(ip, mask)); +#endif } /*