BACKPORT: Smack: ignore null signal in smack_task_kill
authorRafal Krypa <r.krypa@samsung.com>
Mon, 4 Apr 2016 09:14:53 +0000 (11:14 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Mon, 21 Nov 2016 16:02:09 +0000 (17:02 +0100)
Kill with signal number 0 is commonly used for checking PID existence.
Smack treated such cases like any other kills, although no signal is
actually delivered when sig == 0.

Checking permissions when sig == 0 didn't prevent an unprivileged caller
from learning whether PID exists or not. When it existed, kernel returned
EPERM, when it didn't - ESRCH. The only effect of policy check in such
case is noise in audit logs.

This change lets Smack silently ignore kill() invocations with sig == 0.

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
(cherry-picked from upstream 18d872f77cecec2677a394170f26aaeb08562cee)

security/smack/smack_lsm.c

index cb424ba1ac6fe881f2c425899aa873bb0dabb4df..273e6b898d915fa7227397f8a1a7411cfdd0d7b0 100644 (file)
@@ -2244,6 +2244,9 @@ static int smack_task_kill(struct task_struct *p, struct siginfo *info,
        struct smack_known *tkp = smk_of_task_struct(p);
        int rc;
 
+       if (!sig)
+               return 0; /* null signal; existence test */
+
        smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK);
        smk_ad_setfield_u_tsk(&ad, p);
        /*