diff mbox series

net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb()

Message ID 20230913104119.3344592-1-make_ruc2021@163.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1340 this patch: 1340
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 1363 this patch: 1363
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1363 this patch: 1363
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ma Ke Sept. 13, 2023, 10:41 a.m. UTC
In qlcnic_alloc_rx_skb(), when dma_map_single() fails, skb is freed
immediately. And skb could be freed again. This issue could allow a
local attacker to crash the system due to a use-after-free flaw.

Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Simon Horman Sept. 15, 2023, 5:45 a.m. UTC | #1
On Wed, Sep 13, 2023 at 06:41:19PM +0800, Ma Ke wrote:
> In qlcnic_alloc_rx_skb(), when dma_map_single() fails, skb is freed
> immediately. And skb could be freed again. This issue could allow a
> local attacker to crash the system due to a use-after-free flaw.
> 
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
>  drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
> index 41894d154013..6501aaf2b5ce 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
> @@ -832,6 +832,7 @@ static int qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
>  	if (dma_mapping_error(&pdev->dev, dma)) {
>  		adapter->stats.rx_dma_map_error++;
>  		dev_kfree_skb_any(skb);
> +		skb = NULL;
>  		return -ENOMEM;

Hi Ma Ke,

I am a unclear on how skb could be freed a second time.
skb is a local variable which goes out of scope when
the function returns.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
index 41894d154013..6501aaf2b5ce 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
@@ -832,6 +832,7 @@  static int qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
 	if (dma_mapping_error(&pdev->dev, dma)) {
 		adapter->stats.rx_dma_map_error++;
 		dev_kfree_skb_any(skb);
+		skb = NULL;
 		return -ENOMEM;
 	}