]> git.baikalelectronics.ru Git - kernel.git/commit
i40e: fix potential NULL pointer dereferencing
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Mon, 11 Jan 2021 18:11:38 +0000 (18:11 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Jan 2021 03:33:28 +0000 (19:33 -0800)
commit7b57fa14fd4ca8fb5a8d933d77496cdabf6592ba
tree9f9d6acbccbc2c4c93d9fbebfcac0796e995b742
parent2d618d41e4c037911a164bc815eee86d1a22e704
i40e: fix potential NULL pointer dereferencing

Currently, the function i40e_construct_skb_zc only frees the input xdp
buffer when the output skb is successfully built. On error, the
function i40e_clean_rx_irq_zc does not commit anything for the current
packet descriptor and simply exits the packet descriptor processing
loop, with the plan to restart the processing of this descriptor on
the next invocation. Therefore, on error the ring next-to-clean
pointer should not advance, the xdp i.e. *bi buffer should not be
freed and the current buffer info should not be invalidated by setting
*bi to NULL. Therefore, the *bi should only be set to NULL when the
function i40e_construct_skb_zc is successful, otherwise a NULL *bi
will be dereferenced when the work for the current descriptor is
eventually restarted.

Fixes: 8afce9d352b1 ("i40e, xsk: Migrate to new MEM_TYPE_XSK_BUFF_POOL")
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Link: https://lore.kernel.org/r/20210111181138.49757-1-cristian.dumitrescu@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/i40e/i40e_xsk.c