Smack: secmark connections 41/69441/2
authorCasey Schaufler <casey@schaufler-ca.com>
Fri, 13 May 2016 07:47:26 +0000 (16:47 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 17 May 2016 07:12:56 +0000 (00:12 -0700)
If the secmark is available us it on connection as
well as packet delivery.

Change-Id: I9015304ef62ab9a32c8e7740c5d70bd8842da7eb

security/smack/smack_lsm.c

index 3d9f1b69782a72fe63b04a88e2644761bef786f1..5c4bda37baa3f7581d0df1b50fb84ea6f736eff7 100644 (file)
@@ -3926,6 +3926,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)
@@ -3934,6 +3946,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;