qed: Fix use after free in qed_chain_free
authorYuval Basson <ybason@marvell.com>
Sun, 29 Mar 2020 17:32:49 +0000 (20:32 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Mar 2020 18:45:18 +0000 (11:45 -0700)
commit8063f761cd7c17fc1d0018728936e0c33a25388a
tree2c1283ddc185b6114cac3189770fb312b869068e
parent4abc3c04810bab77ae5779adc9f6abb5dad4ac6f
qed: Fix use after free in qed_chain_free

The qed_chain data structure was modified in
commit 1a4a69751f4d ("qed: Chain support for external PBL") to support
receiving an external pbl (due to iWARP FW requirements).
The pages pointed to by the pbl are allocated in qed_chain_alloc
and their virtual address are stored in an virtual addresses array to
enable accessing and freeing the data. The physical addresses however
weren't stored and were accessed directly from the external-pbl
during free.

Destroy-qp flow, leads to freeing the external pbl before the chain is
freed, when the chain is freed it tries accessing the already freed
external pbl, leading to a use-after-free. Therefore we need to store
the physical addresses in additional to the virtual addresses in a
new data structure.

Fixes: 1a4a69751f4d ("qed: Chain support for external PBL")
Signed-off-by: Michal Kalderon <mkalderon@marvell.com>
Signed-off-by: Yuval Bason <ybason@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_dev.c
include/linux/qed/qed_chain.h