Smack: secmark connections 69/36369/1
authorCasey Schaufler <casey@schaufler-ca.com>
Wed, 11 Feb 2015 20:52:32 +0000 (12:52 -0800)
committerRafal Krypa <r.krypa@samsung.com>
Thu, 5 Mar 2015 12:06:07 +0000 (13:06 +0100)
If the secmark is available us it on connection as
well as packet delivery.

Change-Id: I28a4c7b50829f2bcfd6ad784b652485550935855
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smack_lsm.c

index 838a39792b0300f019faa02aae848ee77c397831..db46ddb1716d3b0a367d701f7c9e30cc9b64fd5f 100644 (file)
@@ -3819,6 +3819,18 @@ static int smack_inet_conn_request(struct sock *sk, struct sk_buff *skb,
        }
 #endif /* CONFIG_IPV6 */
 
+#ifdef CONFIG_SECURITY_SMACK_NETFILTER
+       /*
+        * If there is a secmark use it rather than the CIPSO label.
+        * If there is no secmark fall back to CIPSO.
+        * The secmark is assumed to reflect policy better.
+        */
+       if (skb && skb->secmark != 0) {
+               skp = smack_from_secid(skb->secmark);
+               goto access_check;
+       }
+#endif /* CONFIG_SECURITY_SMACK_NETFILTER */
+
        netlbl_secattr_init(&secattr);
        rc = netlbl_skbuff_getattr(skb, family, &secattr);
        if (rc == 0)
@@ -3827,6 +3839,10 @@ static int smack_inet_conn_request(struct sock *sk, struct sk_buff *skb,
                skp = &smack_known_huh;
        netlbl_secattr_destroy(&secattr);
 
+#ifdef CONFIG_SECURITY_SMACK_NETFILTER
+access_check:
+#endif
+
 #ifdef CONFIG_AUDIT
        smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
        ad.a.u.net->family = family;