Skip to content

Commit f0f9756

Browse files
author
James Morris
committed
Merge branch 'smack-for-4.20' of https://github.com/cschaufler/next-smack into next-smack
From Casey: "Here are three patches for Smack for 4.20. Two clean up warnings and one is a rarely encountered ptrace capability check."
2 parents 0d42d73 + b1fed3e commit f0f9756

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

security/smack/smack_lsm.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ static int smk_ptrace_rule_check(struct task_struct *tracer,
421421
struct smk_audit_info ad, *saip = NULL;
422422
struct task_smack *tsp;
423423
struct smack_known *tracer_known;
424+
const struct cred *tracercred;
424425

425426
if ((mode & PTRACE_MODE_NOAUDIT) == 0) {
426427
smk_ad_init(&ad, func, LSM_AUDIT_DATA_TASK);
@@ -429,7 +430,8 @@ static int smk_ptrace_rule_check(struct task_struct *tracer,
429430
}
430431

431432
rcu_read_lock();
432-
tsp = __task_cred(tracer)->security;
433+
tracercred = __task_cred(tracer);
434+
tsp = tracercred->security;
433435
tracer_known = smk_of_task(tsp);
434436

435437
if ((mode & PTRACE_MODE_ATTACH) &&
@@ -439,7 +441,7 @@ static int smk_ptrace_rule_check(struct task_struct *tracer,
439441
rc = 0;
440442
else if (smack_ptrace_rule == SMACK_PTRACE_DRACONIAN)
441443
rc = -EACCES;
442-
else if (capable(CAP_SYS_PTRACE))
444+
else if (smack_privileged_cred(CAP_SYS_PTRACE, tracercred))
443445
rc = 0;
444446
else
445447
rc = -EACCES;
@@ -1841,6 +1843,7 @@ static int smack_file_send_sigiotask(struct task_struct *tsk,
18411843
{
18421844
struct smack_known *skp;
18431845
struct smack_known *tkp = smk_of_task(tsk->cred->security);
1846+
const struct cred *tcred;
18441847
struct file *file;
18451848
int rc;
18461849
struct smk_audit_info ad;
@@ -1854,8 +1857,12 @@ static int smack_file_send_sigiotask(struct task_struct *tsk,
18541857
skp = file->f_security;
18551858
rc = smk_access(skp, tkp, MAY_DELIVER, NULL);
18561859
rc = smk_bu_note("sigiotask", skp, tkp, MAY_DELIVER, rc);
1857-
if (rc != 0 && has_capability(tsk, CAP_MAC_OVERRIDE))
1860+
1861+
rcu_read_lock();
1862+
tcred = __task_cred(tsk);
1863+
if (rc != 0 && smack_privileged_cred(CAP_MAC_OVERRIDE, tcred))
18581864
rc = 0;
1865+
rcu_read_unlock();
18591866

18601867
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK);
18611868
smk_ad_setfield_u_tsk(&ad, tsk);
@@ -3467,7 +3474,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
34673474
*/
34683475
final = &smack_known_star;
34693476
/*
3470-
* No break.
3477+
* Fall through.
34713478
*
34723479
* If a smack value has been set we want to use it,
34733480
* but since tmpfs isn't giving us the opportunity

security/smack/smackfs.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,6 @@ static const struct file_operations smk_ptrace_ops = {
28532853
static int smk_fill_super(struct super_block *sb, void *data, int silent)
28542854
{
28552855
int rc;
2856-
struct inode *root_inode;
28572856

28582857
static const struct tree_descr smack_files[] = {
28592858
[SMK_LOAD] = {
@@ -2917,8 +2916,6 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
29172916
return rc;
29182917
}
29192918

2920-
root_inode = d_inode(sb->s_root);
2921-
29222919
return 0;
29232920
}
29242921

0 commit comments

Comments
 (0)