netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.14-stable] xfrm: Fix a race in the xdst pcpu cache.
@ 2018-01-24  9:13 Steffen Klassert
  2018-01-24 14:57 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Steffen Klassert @ 2018-01-24  9:13 UTC (permalink / raw)
  To: David Miller, stable; +Cc: netdev

commit 76a4201191814a0061cb5c861fafb9ecaa764846 upstream.

We need to run xfrm_resolve_and_create_bundle() with
bottom halves off. Otherwise we may reuse an already
released dst_enty when the xfrm lookup functions are
called from process context.

Fixes: c30d78c14a813db39a647b6a348b428 ("xfrm: add xdst pcpu cache")
Reported-by: Darius Ski <darius.ski@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_policy.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index bc5eae12fb09..bd6b0e7a0ee4 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2063,8 +2063,11 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
 	if (num_xfrms <= 0)
 		goto make_dummy_bundle;
 
+	local_bh_disable();
 	xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,
-						  xflo->dst_orig);
+					      xflo->dst_orig);
+	local_bh_enable();
+
 	if (IS_ERR(xdst)) {
 		err = PTR_ERR(xdst);
 		if (err != -EAGAIN)
@@ -2151,9 +2154,12 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 				goto no_transform;
 			}
 
+			local_bh_disable();
 			xdst = xfrm_resolve_and_create_bundle(
 					pols, num_pols, fl,
 					family, dst_orig);
+			local_bh_enable();
+
 			if (IS_ERR(xdst)) {
 				xfrm_pols_put(pols, num_pols);
 				err = PTR_ERR(xdst);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 4.14-stable] xfrm: Fix a race in the xdst pcpu cache.
  2018-01-24  9:13 [PATCH 4.14-stable] xfrm: Fix a race in the xdst pcpu cache Steffen Klassert
@ 2018-01-24 14:57 ` David Miller
  2018-01-24 15:27   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-01-24 14:57 UTC (permalink / raw)
  To: steffen.klassert; +Cc: stable, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Wed, 24 Jan 2018 10:13:25 +0100

> commit 76a4201191814a0061cb5c861fafb9ecaa764846 upstream.
> 
> We need to run xfrm_resolve_and_create_bundle() with
> bottom halves off. Otherwise we may reuse an already
> released dst_enty when the xfrm lookup functions are
> called from process context.
> 
> Fixes: c30d78c14a813db39a647b6a348b428 ("xfrm: add xdst pcpu cache")
> Reported-by: Darius Ski <darius.ski@gmail.com>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

ACK

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4.14-stable] xfrm: Fix a race in the xdst pcpu cache.
  2018-01-24 14:57 ` David Miller
@ 2018-01-24 15:27   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-01-24 15:27 UTC (permalink / raw)
  To: David Miller; +Cc: steffen.klassert, stable, netdev

On Wed, Jan 24, 2018 at 09:57:06AM -0500, David Miller wrote:
> From: Steffen Klassert <steffen.klassert@secunet.com>
> Date: Wed, 24 Jan 2018 10:13:25 +0100
> 
> > commit 76a4201191814a0061cb5c861fafb9ecaa764846 upstream.
> > 
> > We need to run xfrm_resolve_and_create_bundle() with
> > bottom halves off. Otherwise we may reuse an already
> > released dst_enty when the xfrm lookup functions are
> > called from process context.
> > 
> > Fixes: c30d78c14a813db39a647b6a348b428 ("xfrm: add xdst pcpu cache")
> > Reported-by: Darius Ski <darius.ski@gmail.com>
> > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> 
> ACK

Thanks, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-24 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24  9:13 [PATCH 4.14-stable] xfrm: Fix a race in the xdst pcpu cache Steffen Klassert
2018-01-24 14:57 ` David Miller
2018-01-24 15:27   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).