Skip to content

Commit 615bc21

Browse files
committed
Merge tag 'fixes-v5.8-rc3-a' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem fixes from James Morris: "Two simple fixes for v5.8: - Fix hook iteration and default value for inode_copy_up_xattr (KP Singh) - Fix the key_permission LSM hook function type (Sami Tolvanen)" * tag 'fixes-v5.8-rc3-a' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: security: Fix hook iteration and default value for inode_copy_up_xattr security: fix the key_permission LSM hook function type
2 parents b13f40b + 23e390c commit 615bc21

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

include/linux/lsm_hook_defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ LSM_HOOK(int, 0, inode_listsecurity, struct inode *inode, char *buffer,
150150
size_t buffer_size)
151151
LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid)
152152
LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new)
153-
LSM_HOOK(int, 0, inode_copy_up_xattr, const char *name)
153+
LSM_HOOK(int, -EOPNOTSUPP, inode_copy_up_xattr, const char *name)
154154
LSM_HOOK(int, 0, kernfs_init_security, struct kernfs_node *kn_dir,
155155
struct kernfs_node *kn)
156156
LSM_HOOK(int, 0, file_permission, struct file *file, int mask)
@@ -360,7 +360,7 @@ LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred,
360360
unsigned long flags)
361361
LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key)
362362
LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred,
363-
unsigned perm)
363+
enum key_need_perm need_perm)
364364
LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer)
365365
#endif /* CONFIG_KEYS */
366366

security/security.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,22 @@ EXPORT_SYMBOL(security_inode_copy_up);
14141414

14151415
int security_inode_copy_up_xattr(const char *name)
14161416
{
1417-
return call_int_hook(inode_copy_up_xattr, -EOPNOTSUPP, name);
1417+
struct security_hook_list *hp;
1418+
int rc;
1419+
1420+
/*
1421+
* The implementation can return 0 (accept the xattr), 1 (discard the
1422+
* xattr), -EOPNOTSUPP if it does not know anything about the xattr or
1423+
* any other error code incase of an error.
1424+
*/
1425+
hlist_for_each_entry(hp,
1426+
&security_hook_heads.inode_copy_up_xattr, list) {
1427+
rc = hp->hook.inode_copy_up_xattr(name);
1428+
if (rc != LSM_RET_DEFAULT(inode_copy_up_xattr))
1429+
return rc;
1430+
}
1431+
1432+
return LSM_RET_DEFAULT(inode_copy_up_xattr);
14181433
}
14191434
EXPORT_SYMBOL(security_inode_copy_up_xattr);
14201435

0 commit comments

Comments
 (0)