Skip to content

Commit a3727a8

Browse files
committed
selinux,smack: fix subjective/objective credential use mixups
Jann Horn reported a problem with commit eb1231f ("selinux: clarify task subjective and objective credentials") where some LSM hooks were attempting to access the subjective credentials of a task other than the current task. Generally speaking, it is not safe to access another task's subjective credentials and doing so can cause a number of problems. Further, while looking into the problem, I realized that Smack was suffering from a similar problem brought about by a similar commit 1fb057d ("smack: differentiate between subjective and objective task credentials"). This patch addresses this problem by restoring the use of the task's objective credentials in those cases where the task is other than the current executing task. Not only does this resolve the problem reported by Jann, it is arguably the correct thing to do in these cases. Cc: [email protected] Fixes: eb1231f ("selinux: clarify task subjective and objective credentials") Fixes: 1fb057d ("smack: differentiate between subjective and objective task credentials") Reported-by: Jann Horn <[email protected]> Acked-by: Eric W. Biederman <[email protected]> Acked-by: Casey Schaufler <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 6880fa6 commit a3727a8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

security/selinux/hooks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ static int selinux_ptrace_access_check(struct task_struct *child,
21572157
static int selinux_ptrace_traceme(struct task_struct *parent)
21582158
{
21592159
return avc_has_perm(&selinux_state,
2160-
task_sid_subj(parent), task_sid_obj(current),
2160+
task_sid_obj(parent), task_sid_obj(current),
21612161
SECCLASS_PROCESS, PROCESS__PTRACE, NULL);
21622162
}
21632163

@@ -6222,7 +6222,7 @@ static int selinux_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *m
62226222
struct ipc_security_struct *isec;
62236223
struct msg_security_struct *msec;
62246224
struct common_audit_data ad;
6225-
u32 sid = task_sid_subj(target);
6225+
u32 sid = task_sid_obj(target);
62266226
int rc;
62276227

62286228
isec = selinux_ipc(msq);

security/smack/smack_lsm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ static int smk_curacc_on_task(struct task_struct *p, int access,
20162016
const char *caller)
20172017
{
20182018
struct smk_audit_info ad;
2019-
struct smack_known *skp = smk_of_task_struct_subj(p);
2019+
struct smack_known *skp = smk_of_task_struct_obj(p);
20202020
int rc;
20212021

20222022
smk_ad_init(&ad, caller, LSM_AUDIT_DATA_TASK);
@@ -3480,7 +3480,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
34803480
*/
34813481
static int smack_getprocattr(struct task_struct *p, char *name, char **value)
34823482
{
3483-
struct smack_known *skp = smk_of_task_struct_subj(p);
3483+
struct smack_known *skp = smk_of_task_struct_obj(p);
34843484
char *cp;
34853485
int slen;
34863486

0 commit comments

Comments
 (0)