]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit980d742e6d4df4f180b80e3225964c9ecc6e0668
treeab73eab19bd24075e9ca2f09b588e57d9077a81b
parent01af2c4364ae1515c0bd9302c604255e8f225ad9
xfrm: Fix NULL pointer dereference in xfrm_input when skb_dst_force clears the dst_entry.

BugLink: https://bugs.launchpad.net/bugs/1837477
[ Upstream commit 0152eee6fc3b84298bb6a79961961734e8afa5b8 ]

Since commit 222d7dbd258d ("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 9e1437937807 ("xfrm: Fix NULL pointer dereference when
skb_dst_force clears the dst_entry.")

Fixes: 222d7dbd258d ("net: prevent dst uses after free")
Reported-by: Jean-Philippe Menil <jpmenil@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/xfrm/xfrm_input.c