Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux 3.2 compat: security_inode_init_security() #519

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions config/kernel-security-old-inode-init.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
dnl #
dnl # Linux 3.2 API Change
dnl #
dnl # The security_inode_init_security() function was renamed to
dnl # security_old_inode_init_security and the symbol was reimplemented.
dnl #
dnl # The new security_inode_init_security() function never returns ENOTSUPP
dnl # and *name, *value, or len may be uninitialized on a successful return.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SECURITY_OLD_INODE_INIT_SECURITY], [
AC_MSG_CHECKING([whether security_old_inode_init_security() is available])
tmp_flags="$EXTRA_KCFLAGS"
EXTRA_KCFLAGS="-Werror"
ZFS_LINUX_TRY_COMPILE([
#include <linux/security.h>
],[
security_old_inode_init_security(NULL,NULL,NULL,NULL,NULL,NULL);
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SECURITY_OLD_INODE_INIT_SECURITY, 1,
[security_old_inode_init_security() is available])
],[
AC_MSG_RESULT(no)
])
EXTRA_KCFLAGS="$tmp_flags"
])
1 change: 1 addition & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_D_OBTAIN_ALIAS
ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE
ZFS_AC_KERNEL_TRUNCATE_SETSIZE
ZFS_AC_KERNEL_SECURITY_OLD_INODE_INIT_SECURITY
ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
ZFS_AC_KERNEL_MOUNT_NODEV
ZFS_AC_KERNEL_BDI
Expand Down
5 changes: 5 additions & 0 deletions include/linux/xattr_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ fn(struct inode *ip, const char *name, const void *buffer, \
}
#endif /* HAVE_DENTRY_XATTR_SET */

#ifdef HAVE_SECURITY_OLD_INODE_INIT_SECURITY
#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_old_inode_init_security(ip, dip, qstr, nm, val, len)
#else
#ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_inode_init_security(ip, dip, qstr, nm, val, len)
#else
#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_inode_init_security(ip, dip, nm, val, len)
#endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
#endif /* HAVE_SECURITY_OLD_INODE_INIT_SECURITY */

#endif /* _ZFS_XATTR_H */
29 changes: 14 additions & 15 deletions module/zfs/zpl_xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,26 +610,25 @@ int
zpl_xattr_security_init(struct inode *ip, struct inode *dip,
const struct qstr *qstr)
{
int error;
size_t len;
void *value;
char *name;

error = zpl_security_inode_init_security(ip, dip, qstr,
&name, &value, &len);
if (error) {
if (error == -EOPNOTSUPP)
return 0;
int error;
size_t len;
void *value;
char *name;

return (error);
}
error = zpl_security_inode_init_security(ip, dip, qstr,
&name, &value, &len);
if (error) {
if (error == -EOPNOTSUPP)
return 0;
return (error);
}

error = __zpl_xattr_security_set(ip, name, value, len, 0);

kfree(name);
kfree(value);
kfree(name);
kfree(value);

return (error);
return (error);
}

xattr_handler_t zpl_xattr_security_handler = {
Expand Down