Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ceab0688 authored by Steffen Klassert's avatar Steffen Klassert Committed by Greg Kroah-Hartman
Browse files

xfrm: Fix a race in the xdst pcpu cache.



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: default avatarDarius Ski <darius.ski@gmail.com>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
Acked-by: default avatarDavid Miller <davem@davemloft.net&gt;,>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 19848ca7
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2056,8 +2056,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);
	local_bh_enable();

	if (IS_ERR(xdst)) {
		err = PTR_ERR(xdst);
		if (err != -EAGAIN)
@@ -2144,9 +2147,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);