Skip to contentSkip to conversation

nfp: bpf: Add check for nfp_app_ctrl_msg_alloc()

PATCH Applied Haoxiang Li 3 participants 3 messages Feb 18, 2025 – Feb 20, 2025

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 nfp: bpf: Add check for nfp_app_ctrl_msg_alloc()

Add check for the return value of nfp_app_ctrl_msg_alloc() in nfp_bpf_cmsg_alloc() to prevent null pointer dereference.

Fixes ff3d43f7568c ("nfp: bpf: implement helpers for FW map ops")

---
Changes in v3:
- modify a spell error. Thanks, Kalesh!
Changes in v2:
- remove the bracket for one single-statement. Thanks, Guru!

---
 drivers/net/ethernet/netronome/nfp/bpf/cmsg.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c +2 -0
index 2ec62c8d86e1..59486fe2ad18 100644
@@ -20,6 +20,8 @@ nfp_bpf_cmsg_alloc(struct nfp_app_bpf *bpf, unsigned int size)
 	struct sk_buff *skb;
 
 	skb = nfp_app_ctrl_msg_alloc(bpf->app, size, GFP_KERNEL);
+	if (!skb)
+		return NULL;
 	skb_put(skb, size);
 
 	return skb;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 30 lines · Haoxiang Li

Add check for the return value of nfp_app_ctrl_msg_alloc() in nfp_bpf_cmsg_alloc() to prevent null pointer dereference.

Fixes ff3d43f7568c ("nfp: bpf: implement helpers for FW map ops")

---
Changes in v3:
- modify a spell error. Thanks, Kalesh!
Changes in v2:
- remove the bracket for one single-statement. Thanks, Guru!

---
 drivers/net/ethernet/netronome/nfp/bpf/cmsg.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c +2 -1
index 2ec62c8d86e1..59486fe2ad18 100644
@@ -20,6 +20,8 @@ nfp_bpf_cmsg_alloc(struct nfp_app_bpf *bpf, unsigned int size)
        struct sk_buff *skb;
 
        skb = nfp_app_ctrl_msg_alloc(bpf->app, size, GFP_KERNEL);
+       if (!skb)
+               return NULL;
        skb_put(skb, size);
 
        return skb;
--
Quoted 3 lines

2.25.1

You should wait 24 hours before posting a new version of the patch.

https://docs.kernel.org/process/maintainer-netdev.html#resending-after-review

Signature · 2 lines
Regards,
Kalesh AP
#2 lore raw
In reply to Haoxiang Li
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Tue, 18 Feb 2025 11:04:09 +0800 you wrote:

Add check for the return value of nfp_app_ctrl_msg_alloc() in nfp_bpf_cmsg_alloc() to prevent null pointer dereference.

Fixes ff3d43f7568c ("nfp: bpf: implement helpers for FW map ops")

[...]

Here is the summary with links:
- [net,v3] nfp: bpf: Add check for nfp_app_ctrl_msg_alloc()

    https://git.kernel.org/netdev/net/c/878e7b11736e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html