Skip to content

Commit d1e7f09

Browse files
committed
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
2 parents 246e179 + 7f5056b commit d1e7f09

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ LSM_HOOK(int, 0, sb_clone_mnt_opts, const struct super_block *oldsb,
8080
unsigned long *set_kern_flags)
8181
LSM_HOOK(int, 0, move_mount, const struct path *from_path,
8282
const struct path *to_path)
83-
LSM_HOOK(int, 0, dentry_init_security, struct dentry *dentry,
83+
LSM_HOOK(int, -EOPNOTSUPP, dentry_init_security, struct dentry *dentry,
8484
int mode, const struct qstr *name, const char **xattr_name,
8585
void **ctx, u32 *ctxlen)
8686
LSM_HOOK(int, 0, dentry_create_files_as, struct dentry *dentry, int mode,

security/security.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,19 @@ int security_dentry_init_security(struct dentry *dentry, int mode,
10481048
const char **xattr_name, void **ctx,
10491049
u32 *ctxlen)
10501050
{
1051-
return call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode,
1052-
name, xattr_name, ctx, ctxlen);
1051+
struct security_hook_list *hp;
1052+
int rc;
1053+
1054+
/*
1055+
* Only one module will provide a security context.
1056+
*/
1057+
hlist_for_each_entry(hp, &security_hook_heads.dentry_init_security, list) {
1058+
rc = hp->hook.dentry_init_security(dentry, mode, name,
1059+
xattr_name, ctx, ctxlen);
1060+
if (rc != LSM_RET_DEFAULT(dentry_init_security))
1061+
return rc;
1062+
}
1063+
return LSM_RET_DEFAULT(dentry_init_security);
10531064
}
10541065
EXPORT_SYMBOL(security_dentry_init_security);
10551066

0 commit comments

Comments
 (0)