Skip to content

Commit

Permalink
Make zpl_permission work with 5.12+ kernels
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Ryan Moeller authored and ixhamza committed Jun 20, 2023
1 parent e7904b8 commit e5f1583
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/os/linux/zfs/sys/zpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,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[];

Expand Down
12 changes: 12 additions & 0 deletions module/os/linux/zfs/zpl_xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,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;
Expand All @@ -1495,7 +1499,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++) {
Expand All @@ -1509,7 +1517,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
}

/*
Expand Down

0 comments on commit e5f1583

Please sign in to comment.