]> git.baikalelectronics.ru Git - kernel.git/commit
xfrm: Fix NULL pointer dereference in xfrm_input when skb_dst_force clears the dst_entry.
authorSteffen Klassert <steffen.klassert@secunet.com>
Thu, 22 Nov 2018 06:26:24 +0000 (07:26 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 22 Nov 2018 09:09:39 +0000 (10:09 +0100)
commit02fe2ec9ee8d44d516723c8716f0ad5fbaa01514
tree0c97d1dc87bf2b54971bf0b215ddbd5a837a9fb5
parent9d3fa7c3bfb8a18fee765aaeb1697cb9a56b3266
xfrm: Fix NULL pointer dereference in xfrm_input when skb_dst_force clears the dst_entry.

Since commit a0d9720bfeaa ("net: prevent dst uses after free")
skb_dst_force() might clear the dst_entry attached to the skb.
The xfrm code doesn't expect this to happen, so we crash with
a NULL pointer dereference in this case.

Fix it by checking skb_dst(skb) for NULL after skb_dst_force()
and drop the packet in case the dst_entry was cleared. We also
move the skb_dst_force() to a codepath that is not used when
the transformation was offloaded, because in this case we
don't have a dst_entry attached to the skb.

The output and forwarding path was already fixed by
commit 112434c4291d ("xfrm: Fix NULL pointer dereference when
skb_dst_force clears the dst_entry.")

Fixes: a0d9720bfeaa ("net: prevent dst uses after free")
Reported-by: Jean-Philippe Menil <jpmenil@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_input.c