summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-01-29 07:52:27 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2022-01-29 07:52:27 +0100
commitd1e7f0919ea84911e2ab965418cd502ba6a906e1 (patch)
treed9c8211ad10a522d2a98357b563cb87bf32533f3 /security
parentMerge tag 'docs-5.17-3' of git://git.lwn.net/linux (diff)
parentsecurity, lsm: dentry_init_security() Handle multi LSM registration (diff)
downloadlinux-d1e7f0919ea84911e2ab965418cd502ba6a906e1.tar.xz
linux-d1e7f0919ea84911e2ab965418cd502ba6a906e1.zip
Merge tag 'fixes-v5.17-lsm-ceph-null' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security sybsystem fix from James Morris: "Fix NULL pointer crash in LSM via Ceph, from Vivek Goyal" * tag 'fixes-v5.17-lsm-ceph-null' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: security, lsm: dentry_init_security() Handle multi LSM registration
Diffstat (limited to 'security')
-rw-r--r--security/security.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/security/security.c b/security/security.c
index 3d4eb474f35b..22261d79f333 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1048,8 +1048,19 @@ int security_dentry_init_security(struct dentry *dentry, int mode,
const char **xattr_name, void **ctx,
u32 *ctxlen)
{
- return call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode,
- name, xattr_name, ctx, ctxlen);
+ struct security_hook_list *hp;
+ int rc;
+
+ /*
+ * Only one module will provide a security context.
+ */
+ hlist_for_each_entry(hp, &security_hook_heads.dentry_init_security, list) {
+ rc = hp->hook.dentry_init_security(dentry, mode, name,
+ xattr_name, ctx, ctxlen);
+ if (rc != LSM_RET_DEFAULT(dentry_init_security))
+ return rc;
+ }
+ return LSM_RET_DEFAULT(dentry_init_security);
}
EXPORT_SYMBOL(security_dentry_init_security);