diff options
| author | Andreas Gruenbacher <agruenba@redhat.com> | 2016-09-29 11:48:42 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-10-07 20:10:44 -0400 |
| commit | 5d6c31910bc0713e37628dc0ce677dcb13c8ccf4 (patch) | |
| tree | a28f96e71f09da2fbbde50882d56e5d5657c0ede /security/selinux | |
| parent | f5c244383725a6de06bc62fa7c54c0ea0d942eec (diff) | |
xattr: Add __vfs_{get,set,remove}xattr helpers
Right now, various places in the kernel check for the existence of
getxattr, setxattr, and removexattr inode operations and directly call
those operations. Switch to helper functions and test for the IOP_XATTR
flag instead.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security/selinux')
| -rw-r--r-- | security/selinux/hooks.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 13185a6c266a..3db31ac7986b 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -507,14 +507,14 @@ static int sb_finish_set_opts(struct super_block *sb) | |||
| 507 | the root directory. -ENODATA is ok, as this may be | 507 | the root directory. -ENODATA is ok, as this may be |
| 508 | the first boot of the SELinux kernel before we have | 508 | the first boot of the SELinux kernel before we have |
| 509 | assigned xattr values to the filesystem. */ | 509 | assigned xattr values to the filesystem. */ |
| 510 | if (!root_inode->i_op->getxattr) { | 510 | if (!(root_inode->i_opflags & IOP_XATTR)) { |
| 511 | printk(KERN_WARNING "SELinux: (dev %s, type %s) has no " | 511 | printk(KERN_WARNING "SELinux: (dev %s, type %s) has no " |
| 512 | "xattr support\n", sb->s_id, sb->s_type->name); | 512 | "xattr support\n", sb->s_id, sb->s_type->name); |
| 513 | rc = -EOPNOTSUPP; | 513 | rc = -EOPNOTSUPP; |
| 514 | goto out; | 514 | goto out; |
| 515 | } | 515 | } |
| 516 | rc = root_inode->i_op->getxattr(root, root_inode, | 516 | |
| 517 | XATTR_NAME_SELINUX, NULL, 0); | 517 | rc = __vfs_getxattr(root, root_inode, XATTR_NAME_SELINUX, NULL, 0); |
| 518 | if (rc < 0 && rc != -ENODATA) { | 518 | if (rc < 0 && rc != -ENODATA) { |
| 519 | if (rc == -EOPNOTSUPP) | 519 | if (rc == -EOPNOTSUPP) |
| 520 | printk(KERN_WARNING "SELinux: (dev %s, type " | 520 | printk(KERN_WARNING "SELinux: (dev %s, type " |
| @@ -1410,11 +1410,10 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
| 1410 | case SECURITY_FS_USE_NATIVE: | 1410 | case SECURITY_FS_USE_NATIVE: |
| 1411 | break; | 1411 | break; |
| 1412 | case SECURITY_FS_USE_XATTR: | 1412 | case SECURITY_FS_USE_XATTR: |
| 1413 | if (!inode->i_op->getxattr) { | 1413 | if (!(inode->i_opflags & IOP_XATTR)) { |
| 1414 | isec->sid = sbsec->def_sid; | 1414 | isec->sid = sbsec->def_sid; |
| 1415 | break; | 1415 | break; |
| 1416 | } | 1416 | } |
| 1417 | |||
| 1418 | /* Need a dentry, since the xattr API requires one. | 1417 | /* Need a dentry, since the xattr API requires one. |
| 1419 | Life would be simpler if we could just pass the inode. */ | 1418 | Life would be simpler if we could just pass the inode. */ |
| 1420 | if (opt_dentry) { | 1419 | if (opt_dentry) { |
| @@ -1445,14 +1444,12 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
| 1445 | goto out_unlock; | 1444 | goto out_unlock; |
| 1446 | } | 1445 | } |
| 1447 | context[len] = '\0'; | 1446 | context[len] = '\0'; |
| 1448 | rc = inode->i_op->getxattr(dentry, inode, XATTR_NAME_SELINUX, | 1447 | rc = __vfs_getxattr(dentry, inode, XATTR_NAME_SELINUX, context, len); |
| 1449 | context, len); | ||
| 1450 | if (rc == -ERANGE) { | 1448 | if (rc == -ERANGE) { |
| 1451 | kfree(context); | 1449 | kfree(context); |
| 1452 | 1450 | ||
| 1453 | /* Need a larger buffer. Query for the right size. */ | 1451 | /* Need a larger buffer. Query for the right size. */ |
| 1454 | rc = inode->i_op->getxattr(dentry, inode, XATTR_NAME_SELINUX, | 1452 | rc = __vfs_getxattr(dentry, inode, XATTR_NAME_SELINUX, NULL, 0); |
| 1455 | NULL, 0); | ||
| 1456 | if (rc < 0) { | 1453 | if (rc < 0) { |
| 1457 | dput(dentry); | 1454 | dput(dentry); |
| 1458 | goto out_unlock; | 1455 | goto out_unlock; |
| @@ -1465,9 +1462,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
| 1465 | goto out_unlock; | 1462 | goto out_unlock; |
| 1466 | } | 1463 | } |
| 1467 | context[len] = '\0'; | 1464 | context[len] = '\0'; |
| 1468 | rc = inode->i_op->getxattr(dentry, inode, | 1465 | rc = __vfs_getxattr(dentry, inode, XATTR_NAME_SELINUX, context, len); |
| 1469 | XATTR_NAME_SELINUX, | ||
| 1470 | context, len); | ||
| 1471 | } | 1466 | } |
| 1472 | dput(dentry); | 1467 | dput(dentry); |
| 1473 | if (rc < 0) { | 1468 | if (rc < 0) { |
