Skip to content

Commit 068c3af

Browse files
rincebrainBtbN
authored andcommitted
Bend zpl_set_acl to permit the new userns* parameter
Just like openzfs#12087, the set_acl signature changed with all the bolted-on *userns parameters, which disabled set_acl usage, and caused openzfs#12076. Turn zpl_set_acl into zpl_set_acl and zpl_set_acl_impl, and add a new configure test for the new version. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes openzfs#12076 Closes openzfs#12093
1 parent 6e87a2a commit 068c3af

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed

config/kernel-acl.m4

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,22 @@ dnl #
189189
dnl # 3.14 API change,
190190
dnl # Check if inode_operations contains the function set_acl
191191
dnl #
192+
dnl # 5.12 API change,
193+
dnl # set_acl() added a user_namespace* parameter first
194+
dnl #
192195
AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL], [
196+
ZFS_LINUX_TEST_SRC([inode_operations_set_acl_userns], [
197+
#include <linux/fs.h>
198+
199+
int set_acl_fn(struct user_namespace *userns,
200+
struct inode *inode, struct posix_acl *acl,
201+
int type) { return 0; }
202+
203+
static const struct inode_operations
204+
iops __attribute__ ((unused)) = {
205+
.set_acl = set_acl_fn,
206+
};
207+
],[])
193208
ZFS_LINUX_TEST_SRC([inode_operations_set_acl], [
194209
#include <linux/fs.h>
195210
@@ -205,11 +220,17 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL], [
205220

206221
AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [
207222
AC_MSG_CHECKING([whether iops->set_acl() exists])
208-
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [
223+
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns], [
209224
AC_MSG_RESULT(yes)
210225
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
226+
AC_DEFINE(HAVE_SET_ACL_USERNS, 1, [iops->set_acl() takes 4 args])
211227
],[
212-
AC_MSG_RESULT(no)
228+
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [
229+
AC_MSG_RESULT(yes)
230+
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists, takes 3 args])
231+
],[
232+
AC_MSG_RESULT(no)
233+
])
213234
])
214235
])
215236

include/os/linux/zfs/sys/zpl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
6363
const struct qstr *qstr);
6464
#if defined(CONFIG_FS_POSIX_ACL)
6565
#if defined(HAVE_SET_ACL)
66+
#if defined(HAVE_SET_ACL_USERNS)
67+
extern int zpl_set_acl(struct user_namespace *userns, struct inode *ip,
68+
struct posix_acl *acl, int type);
69+
#else
6670
extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
71+
#endif /* HAVE_SET_ACL_USERNS */
6772
#endif /* HAVE_SET_ACL */
6873
extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
6974
extern int zpl_init_acl(struct inode *ip, struct inode *dir);

module/os/linux/zfs/zpl_xattr.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -926,11 +926,8 @@ xattr_handler_t zpl_xattr_security_handler = {
926926
* attribute implemented by filesystems in the kernel." - xattr(7)
927927
*/
928928
#ifdef CONFIG_FS_POSIX_ACL
929-
#ifndef HAVE_SET_ACL
930-
static
931-
#endif
932-
int
933-
zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type)
929+
static int
930+
zpl_set_acl_impl(struct inode *ip, struct posix_acl *acl, int type)
934931
{
935932
char *name, *value = NULL;
936933
int error = 0;
@@ -1002,6 +999,19 @@ zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type)
1002999
return (error);
10031000
}
10041001

1002+
#ifdef HAVE_SET_ACL
1003+
int
1004+
#ifdef HAVE_SET_ACL_USERNS
1005+
zpl_set_acl(struct user_namespace *userns, struct inode *ip,
1006+
struct posix_acl *acl, int type)
1007+
#else
1008+
zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type)
1009+
#endif /* HAVE_SET_ACL_USERNS */
1010+
{
1011+
return (zpl_set_acl_impl(ip, acl, type));
1012+
}
1013+
#endif /* HAVE_SET_ACL */
1014+
10051015
struct posix_acl *
10061016
zpl_get_acl(struct inode *ip, int type)
10071017
{
@@ -1083,7 +1093,7 @@ zpl_init_acl(struct inode *ip, struct inode *dir)
10831093
umode_t mode;
10841094

10851095
if (S_ISDIR(ip->i_mode)) {
1086-
error = zpl_set_acl(ip, acl, ACL_TYPE_DEFAULT);
1096+
error = zpl_set_acl_impl(ip, acl, ACL_TYPE_DEFAULT);
10871097
if (error)
10881098
goto out;
10891099
}
@@ -1093,8 +1103,10 @@ zpl_init_acl(struct inode *ip, struct inode *dir)
10931103
if (error >= 0) {
10941104
ip->i_mode = mode;
10951105
zfs_mark_inode_dirty(ip);
1096-
if (error > 0)
1097-
error = zpl_set_acl(ip, acl, ACL_TYPE_ACCESS);
1106+
if (error > 0) {
1107+
error = zpl_set_acl_impl(ip, acl,
1108+
ACL_TYPE_ACCESS);
1109+
}
10981110
}
10991111
}
11001112
out:
@@ -1121,7 +1133,7 @@ zpl_chmod_acl(struct inode *ip)
11211133

11221134
error = __posix_acl_chmod(&acl, GFP_KERNEL, ip->i_mode);
11231135
if (!error)
1124-
error = zpl_set_acl(ip, acl, ACL_TYPE_ACCESS);
1136+
error = zpl_set_acl_impl(ip, acl, ACL_TYPE_ACCESS);
11251137

11261138
zpl_posix_acl_release(acl);
11271139

@@ -1250,8 +1262,7 @@ __zpl_xattr_acl_set_access(struct inode *ip, const char *name,
12501262
} else {
12511263
acl = NULL;
12521264
}
1253-
1254-
error = zpl_set_acl(ip, acl, type);
1265+
error = zpl_set_acl_impl(ip, acl, type);
12551266
zpl_posix_acl_release(acl);
12561267

12571268
return (error);
@@ -1291,7 +1302,7 @@ __zpl_xattr_acl_set_default(struct inode *ip, const char *name,
12911302
acl = NULL;
12921303
}
12931304

1294-
error = zpl_set_acl(ip, acl, type);
1305+
error = zpl_set_acl_impl(ip, acl, type);
12951306
zpl_posix_acl_release(acl);
12961307

12971308
return (error);

0 commit comments

Comments
 (0)