ethernet:enic: Fix a use after free bug in enic_hard_start_xmit
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Sun, 2 May 2021 11:58:18 +0000 (04:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:13:06 +0000 (10:13 +0200)
commit7afdd6aba95c8a526038e7abe283eeac3e4320f1
tree5b4e323acf708865a8323de35c01a2d6a5b05898
parent3d808916d256b49b971b55eebedece7b34e1d6a2
ethernet:enic: Fix a use after free bug in enic_hard_start_xmit

[ Upstream commit 643001b47adc844ae33510c4bb93c236667008a3 ]

In enic_hard_start_xmit, it calls enic_queue_wq_skb(). Inside
enic_queue_wq_skb, if some error happens, the skb will be freed
by dev_kfree_skb(skb). But the freed skb is still used in
skb_tx_timestamp(skb).

My patch makes enic_queue_wq_skb() return error and goto spin_unlock()
incase of error. The solution is provided by Govind.
See https://lkml.org/lkml/2021/4/30/961.

Fixes: fb7516d42478e ("enic: add sw timestamp support")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Acked-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/cisco/enic/enic_main.c