Skip to content

Commit b1e3a56

Browse files
committed
xfrm: Fix NULL pointer dereference on policy lookup
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: f203b76 ("xfrm: Add virtual xfrm interfaces") Signed-off-by: Steffen Klassert <[email protected]>
1 parent 68dc022 commit b1e3a56

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ static inline int __xfrm_policy_check2(struct sock *sk, int dir,
10971097
return __xfrm_policy_check(sk, ndir, skb, family);
10981098

10991099
return (!net->xfrm.policy_count[dir] && !secpath_exists(skb)) ||
1100-
(skb_dst(skb)->flags & DST_NOPOLICY) ||
1100+
(skb_dst(skb) && (skb_dst(skb)->flags & DST_NOPOLICY)) ||
11011101
__xfrm_policy_check(sk, ndir, skb, family);
11021102
}
11031103

0 commit comments

Comments
 (0)