mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Linux 7.0: posix_acl_to_xattr() now allocates memory
Kernel devs noted that almost all callers to posix_acl_to_xattr() would check the ACL value size and allocate a buffer before make the call. To reduce the repetition, they've changed it to allocate this buffer internally and return it. Unfortunately that's not true for us; most of our calls are from xattr_handler->get() to convert a stored ACL to an xattr, and that call provides a buffer. For now we have no other option, so this commit detects the new version and wraps to copy the value back into the provided buffer and then free it. Sponsored-by: TrueNAS Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <rob.norris@truenas.com> Closes #18216
This commit is contained in:
committed by
Brian Behlendorf
parent
204de946eb
commit
d34fd6cff3
@@ -130,10 +130,27 @@ zpl_acl_from_xattr(const void *value, int size)
|
||||
return (posix_acl_from_xattr(kcred->user_ns, value, size));
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux 7.0 API change. posix_acl_to_xattr() changed from filling the
|
||||
* caller-provided buffer to allocating a buffer with enough space and
|
||||
* returning it. We wrap this up by copying the result into the provided
|
||||
* buffer and freeing the allocated buffer.
|
||||
*/
|
||||
static inline int
|
||||
zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
|
||||
{
|
||||
#ifdef HAVE_POSIX_ACL_TO_XATTR_ALLOC
|
||||
size_t s = 0;
|
||||
void *v = posix_acl_to_xattr(kcred->user_ns, acl, &s,
|
||||
kmem_flags_convert(KM_SLEEP));
|
||||
if (v == NULL)
|
||||
return (-ENOMEM);
|
||||
memcpy(value, v, MIN(size, s));
|
||||
kfree(v);
|
||||
return (0);
|
||||
#else
|
||||
return (posix_acl_to_xattr(kcred->user_ns, acl, value, size));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* _ZFS_XATTR_H */
|
||||
|
||||
Reference in New Issue
Block a user