Skip to content

Commit 169ce0c

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: fix residual uses of current_security() for the SELinux blob
We need to use selinux_cred() to fetch the SELinux cred blob instead of directly using current->security or current_security(). There were a couple of lingering uses of current_security() in the SELinux code that were apparently missed during the earlier conversions. IIUC, this would only manifest as a bug if multiple security modules including SELinux are enabled and SELinux is not first in the lsm order. After this change, there appear to be no other users of current_security() in-tree; perhaps we should remove it altogether. Fixes: bbd3662 ("Infrastructure management of the cred security blob") Signed-off-by: Stephen Smalley <[email protected]> Acked-by: Casey Schaufler <[email protected]> Reviewed-by: James Morris <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 116f21b commit 169ce0c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,7 @@ static int selinux_inode_copy_up_xattr(const char *name)
34353435
static int selinux_kernfs_init_security(struct kernfs_node *kn_dir,
34363436
struct kernfs_node *kn)
34373437
{
3438-
const struct task_security_struct *tsec = current_security();
3438+
const struct task_security_struct *tsec = selinux_cred(current_cred());
34393439
u32 parent_sid, newsid, clen;
34403440
int rc;
34413441
char *context;

security/selinux/include/objsec.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ struct task_security_struct {
4040
u32 sockcreate_sid; /* fscreate SID */
4141
};
4242

43-
/*
44-
* get the subjective security ID of the current task
45-
*/
46-
static inline u32 current_sid(void)
47-
{
48-
const struct task_security_struct *tsec = current_security();
49-
50-
return tsec->sid;
51-
}
52-
5343
enum label_initialized {
5444
LABEL_INVALID, /* invalid or not initialized */
5545
LABEL_INITIALIZED, /* initialized */
@@ -188,4 +178,14 @@ static inline struct ipc_security_struct *selinux_ipc(
188178
return ipc->security + selinux_blob_sizes.lbs_ipc;
189179
}
190180

181+
/*
182+
* get the subjective security ID of the current task
183+
*/
184+
static inline u32 current_sid(void)
185+
{
186+
const struct task_security_struct *tsec = selinux_cred(current_cred());
187+
188+
return tsec->sid;
189+
}
190+
191191
#endif /* _SELINUX_OBJSEC_H_ */

0 commit comments

Comments
 (0)