]> git.itanic.dy.fi Git - linux-stable/commit
bnxt: prevent skb UAF after handing over to PTP worker
authorJakub Kicinski <kuba@kernel.org>
Wed, 21 Sep 2022 20:10:05 +0000 (13:10 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:11:53 +0000 (11:11 +0200)
commit08483e4c0c83b221b8891434a04cec405dee94a6
tree50e584f29658222a0efcda07759adcc51b4aab3d
parentf8162aed962be8fa07445b2b5928e84ab40dd8d7
bnxt: prevent skb UAF after handing over to PTP worker

[ Upstream commit c31f26c8f69f776759cbbdfb38e40ea91aa0dd65 ]

When reading the timestamp is required bnxt_tx_int() hands
over the ownership of the completed skb to the PTP worker.
The skb should not be used afterwards, as the worker may
run before the rest of our code and free the skb, leading
to a use-after-free.

Since dev_kfree_skb_any() accepts NULL make the loss of
ownership more obvious and set skb to NULL.

Fixes: 83bb623c968e ("bnxt_en: Transmit and retrieve packet timestamps")
Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20220921201005.335390-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c