All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ipsec] xfrm: Fix NULL pointer dereference on policy lookup
@ 2021-03-23  8:26 Steffen Klassert
  2021-03-25  8:45 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: Steffen Klassert @ 2021-03-23  8:26 UTC (permalink / raw)
  To: netdev

When xfrm interfaces are used in combination with namespaces
and ESP offload, we get a dst_entry NULL pointer dereference.
This is because we don't have a dst_entry attached in the ESP
offloading case and we need to do a policy lookup before the
namespace transition.

Fix this by expicit checking of skb_dst(skb) before accessing it.

Fixes: f203b76d78092 ("xfrm: Add virtual xfrm interfaces")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 include/net/xfrm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index b2a06f10b62c..fdb7e40a61e9 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1097,7 +1097,7 @@ static inline int __xfrm_policy_check2(struct sock *sk, int dir,
 		return __xfrm_policy_check(sk, ndir, skb, family);
 
 	return	(!net->xfrm.policy_count[dir] && !secpath_exists(skb)) ||
-		(skb_dst(skb)->flags & DST_NOPOLICY) ||
+		(skb_dst(skb) && (skb_dst(skb)->flags & DST_NOPOLICY)) ||
 		__xfrm_policy_check(sk, ndir, skb, family);
 }
 
-- 
2.25.1


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

* Re: [PATCH ipsec] xfrm: Fix NULL pointer dereference on policy lookup
  2021-03-23  8:26 [PATCH ipsec] xfrm: Fix NULL pointer dereference on policy lookup Steffen Klassert
@ 2021-03-25  8:45 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2021-03-25  8:45 UTC (permalink / raw)
  To: netdev

On Tue, Mar 23, 2021 at 09:26:44AM +0100, Steffen Klassert wrote:
> When xfrm interfaces are used in combination with namespaces
> and ESP offload, we get a dst_entry NULL pointer dereference.
> This is because we don't have a dst_entry attached in the ESP
> offloading case and we need to do a policy lookup before the
> namespace transition.
> 
> Fix this by expicit checking of skb_dst(skb) before accessing it.
> 
> Fixes: f203b76d78092 ("xfrm: Add virtual xfrm interfaces")
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

Now applied.

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

end of thread, other threads:[~2021-03-25  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  8:26 [PATCH ipsec] xfrm: Fix NULL pointer dereference on policy lookup Steffen Klassert
2021-03-25  8:45 ` Steffen Klassert

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.