From: Casey Schaufler Date: Wed, 11 Feb 2015 20:52:32 +0000 (-0800) Subject: BACKPORT: Smack: secmark connections X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6951a0138758cccea609cb302d69b6277426306a;p=platform%2Fkernel%2Flinux-stable.git BACKPORT: Smack: secmark connections If the secmark is available us it on connection as well as packet delivery. Signed-off-by: Casey Schaufler (cherry-picked from upstream 7f368ad34f0657f4bc39bf5bad6692b5a81a1194) --- diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 227d54e2d959..53f3b0f8e97c 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -3834,6 +3834,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) @@ -3842,6 +3854,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;