Smack: Assign smack_known_web label for kernel thread's socket in the sk_alloc_securi...
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / security / smack / smack_lsm.c
index f0cea06..7e800c6 100644 (file)
@@ -2145,8 +2145,16 @@ static int smack_sk_alloc_security(struct sock *sk, int family, gfp_t gfp_flags)
        if (ssp == NULL)
                return -ENOMEM;
 
-       ssp->smk_in = skp;
-       ssp->smk_out = skp;
+       /*
+        * Sockets created by kernel threads receive web label.
+        */
+       if (unlikely(current->flags & PF_KTHREAD)) {
+               ssp->smk_in = &smack_known_web;
+               ssp->smk_out = &smack_known_web;
+       } else {
+               ssp->smk_in = skp;
+               ssp->smk_out = skp;
+       }
        ssp->smk_packet = NULL;
 
        sk->sk_security = ssp;