From: Stephen Smalley <sds@tycho.nsa.gov> To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov Cc: paul@paul-moore.com, Stephen Smalley <sds@tycho.nsa.gov> Subject: [RFC PATCH] xfrm: fix regression introduced by xdst pcpu cache Date: Fri, 27 Oct 2017 11:28:22 -0400 [thread overview] Message-ID: <20171027152822.16406-1-sds@tycho.nsa.gov> (raw) commit ec30d78c14a813db39a647b6a348b4286 ("xfrm: add xdst pcpu cache") introduced a regression in the use of labeled IPSEC. The cache was only checking that the policies are the same, but did not validate that the policy, state, and flow matched with respect to security context labeling. As a result, the wrong SA could be used and the receiver could end up performing permission checking and providing SO_PEERSEC or SCM_SECURITY values for the wrong security context. This was triggering failures in the selinux-testsuite. The security_xfrm_state_pol_flow_match() hook exists for this purpose and is already called elsewhere from the xfrm state code for matching purposes. Add a call to this hook when validating the cache entry. With this change, the selinux-testsuite passes all tests again. Fixes: ec30d78c14a813db39a647b6a348b4286ba4abf5 ("xfrm: add xdst pcpu cache") Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> --- Sending this as an RFC to lsm and selinux for comments before sending it to netdev. See https://github.com/SELinuxProject/selinux-kernel/issues/36 for earlier discussion about the bug. net/xfrm/xfrm_policy.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index f062539..e7ec47f 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1820,6 +1820,8 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols, !xfrm_pol_dead(xdst) && memcmp(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols) == 0 && + security_xfrm_state_pol_flow_match(xdst->u.dst.xfrm, + xdst->pols[0], fl) && xfrm_bundle_ok(xdst)) { dst_hold(&xdst->u.dst); return xdst; -- 2.9.5
WARNING: multiple messages have this Message-ID (diff)
From: sds@tycho.nsa.gov (Stephen Smalley) To: linux-security-module@vger.kernel.org Subject: [RFC PATCH] xfrm: fix regression introduced by xdst pcpu cache Date: Fri, 27 Oct 2017 11:28:22 -0400 [thread overview] Message-ID: <20171027152822.16406-1-sds@tycho.nsa.gov> (raw) commit ec30d78c14a813db39a647b6a348b4286 ("xfrm: add xdst pcpu cache") introduced a regression in the use of labeled IPSEC. The cache was only checking that the policies are the same, but did not validate that the policy, state, and flow matched with respect to security context labeling. As a result, the wrong SA could be used and the receiver could end up performing permission checking and providing SO_PEERSEC or SCM_SECURITY values for the wrong security context. This was triggering failures in the selinux-testsuite. The security_xfrm_state_pol_flow_match() hook exists for this purpose and is already called elsewhere from the xfrm state code for matching purposes. Add a call to this hook when validating the cache entry. With this change, the selinux-testsuite passes all tests again. Fixes: ec30d78c14a813db39a647b6a348b4286ba4abf5 ("xfrm: add xdst pcpu cache") Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> --- Sending this as an RFC to lsm and selinux for comments before sending it to netdev. See https://github.com/SELinuxProject/selinux-kernel/issues/36 for earlier discussion about the bug. net/xfrm/xfrm_policy.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index f062539..e7ec47f 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1820,6 +1820,8 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols, !xfrm_pol_dead(xdst) && memcmp(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols) == 0 && + security_xfrm_state_pol_flow_match(xdst->u.dst.xfrm, + xdst->pols[0], fl) && xfrm_bundle_ok(xdst)) { dst_hold(&xdst->u.dst); return xdst; -- 2.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2017-10-27 15:28 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-10-27 15:28 Stephen Smalley [this message] 2017-10-27 15:28 ` [RFC PATCH] xfrm: fix regression introduced by xdst pcpu cache Stephen Smalley 2017-10-30 14:58 Stephen Smalley 2017-10-30 14:58 ` Stephen Smalley 2017-10-31 11:11 ` Florian Westphal 2017-10-31 11:11 ` Florian Westphal [not found] ` <20171031111122.GB7663-E0PNVn5OA6ohrxcnuTQ+TQ@public.gmane.org> 2017-10-31 13:43 ` Stephen Smalley 2017-10-31 13:43 ` Stephen Smalley 2017-10-31 13:43 ` Stephen Smalley 2017-10-31 14:00 ` Stephen Smalley 2017-10-31 14:00 ` Stephen Smalley 2017-10-31 14:15 ` Florian Westphal 2017-10-31 14:15 ` Florian Westphal 2017-10-31 20:39 ` Paul Moore 2017-10-31 20:39 ` Paul Moore 2017-10-31 23:08 ` Florian Westphal 2017-10-31 23:08 ` Florian Westphal 2017-11-01 14:05 ` Stephen Smalley 2017-11-01 14:05 ` Stephen Smalley 2017-11-01 21:39 ` Paul Moore 2017-11-01 21:39 ` Paul Moore 2017-11-02 12:58 ` Stephen Smalley 2017-11-02 12:58 ` Stephen Smalley 2017-11-02 22:37 ` Paul Moore 2017-11-02 22:37 ` Paul Moore
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20171027152822.16406-1-sds@tycho.nsa.gov \ --to=sds@tycho.nsa.gov \ --cc=linux-security-module@vger.kernel.org \ --cc=paul@paul-moore.com \ --cc=selinux@tycho.nsa.gov \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.