All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] qede: confirm skb is allocated before using
@ 2022-04-06 11:19   ` Jamie Bainbridge
  0 siblings, 0 replies; 4+ messages in thread
From: Jamie Bainbridge @ 2022-04-06  1:58 UTC (permalink / raw)
  To: Ariel Elior, Manish Chopra, David S. Miller, Jakub Kicinski, Paolo Abeni
  Cc: Jamie Bainbridge, Manish Chopra, Ariel Elior, netdev, linux-kernel

qede_build_skb() assumes build_skb() always works and goes straight
to skb_reserve(). However, build_skb() can fail under memory pressure.
This results in a kernel panic because the skb to reserve is NULL.

Add a check in case build_skb() failed to allocate and return NULL.

The NULL return is handled correctly in callers to qede_build_skb().

Fixes: 8a8633978b842 ("qede: Add build_skb() support.")
Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
---
 drivers/net/ethernet/qlogic/qede/qede_fp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_fp.c b/drivers/net/ethernet/qlogic/qede/qede_fp.c
index b242000a77fd8db322672e541df074be9b5ce9ef..b7cc36589f592e995e3a12bb80bc7c8e3af7dc42 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_fp.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_fp.c
@@ -748,6 +748,9 @@ qede_build_skb(struct qede_rx_queue *rxq,
 	buf = page_address(bd->data) + bd->page_offset;
 	skb = build_skb(buf, rxq->rx_buf_seg_size);
 
+	if (unlikely(!skb))
+		return NULL;
+
 	skb_reserve(skb, pad);
 	skb_put(skb, len);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net] qede: confirm skb is allocated before using
@ 2022-04-06 11:19   ` Jamie Bainbridge
  0 siblings, 0 replies; 4+ messages in thread
From: Jamie Bainbridge @ 2022-04-06 11:19 UTC (permalink / raw)
  To: Ariel Elior, Manish Chopra, David S. Miller, Jakub Kicinski, Paolo Abeni
  Cc: Jamie Bainbridge, Ariel Elior, Manish Chopra, netdev, linux-kernel

qede_build_skb() assumes build_skb() always works and goes straight
to skb_reserve(). However, build_skb() can fail under memory pressure.
This results in a kernel panic because the skb to reserve is NULL.

Add a check in case build_skb() failed to allocate and return NULL.

The NULL return is handled correctly in callers to qede_build_skb().

Fixes: 8a8633978b842 ("qede: Add build_skb() support.")
Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
---
 drivers/net/ethernet/qlogic/qede/qede_fp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_fp.c b/drivers/net/ethernet/qlogic/qede/qede_fp.c
index b242000a77fd8db322672e541df074be9b5ce9ef..b7cc36589f592e995e3a12bb80bc7c8e3af7dc42 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_fp.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_fp.c
@@ -748,6 +748,9 @@ qede_build_skb(struct qede_rx_queue *rxq,
 	buf = page_address(bd->data) + bd->page_offset;
 	skb = build_skb(buf, rxq->rx_buf_seg_size);
 
+	if (unlikely(!skb))
+		return NULL;
+
 	skb_reserve(skb, pad);
 	skb_put(skb, len);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] qede: confirm skb is allocated before using
  2022-04-06 11:19   ` Jamie Bainbridge
  (?)
@ 2022-04-06 14:20   ` patchwork-bot+netdevbpf
  -1 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-06 14:20 UTC (permalink / raw)
  To: Jamie Bainbridge
  Cc: aelior, manishc, davem, kuba, pabeni, ariel.elior, manish.chopra,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed,  6 Apr 2022 21:19:19 +1000 you wrote:
> qede_build_skb() assumes build_skb() always works and goes straight
> to skb_reserve(). However, build_skb() can fail under memory pressure.
> This results in a kernel panic because the skb to reserve is NULL.
> 
> Add a check in case build_skb() failed to allocate and return NULL.
> 
> The NULL return is handled correctly in callers to qede_build_skb().
> 
> [...]

Here is the summary with links:
  - [net] qede: confirm skb is allocated before using
    https://git.kernel.org/netdev/net/c/4e910dbe3650

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] qede: confirm skb is allocated before using
  2022-04-06 11:19   ` Jamie Bainbridge
  (?)
  (?)
@ 2022-04-07  6:02   ` Jakub Kicinski
  -1 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2022-04-07  6:02 UTC (permalink / raw)
  To: Jamie Bainbridge
  Cc: Ariel Elior, Manish Chopra, David S. Miller, Paolo Abeni,
	Manish Chopra, Ariel Elior, netdev, linux-kernel

On Wed,  6 Apr 2022 11:58:09 +1000 Jamie Bainbridge wrote:
> qede_build_skb() assumes build_skb() always works and goes straight
> to skb_reserve(). However, build_skb() can fail under memory pressure.
> This results in a kernel panic because the skb to reserve is NULL.
> 
> Add a check in case build_skb() failed to allocate and return NULL.
> 
> The NULL return is handled correctly in callers to qede_build_skb().
> 
> Fixes: 8a8633978b842 ("qede: Add build_skb() support.")
> Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>

FTR commit 4e910dbe3650 ("qede: confirm skb is allocated before using")
in net.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-07  6:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  1:58 [PATCH net] qede: confirm skb is allocated before using Jamie Bainbridge
2022-04-06  1:58 ` Jamie Bainbridge
2022-04-06 11:19   ` Jamie Bainbridge
2022-04-06 14:20   ` patchwork-bot+netdevbpf
2022-04-07  6:02   ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.