Skip to contentSkip to conversation

ethernet/netronome/nfp: Fix a use after free in nfp_bpf_ctrl_msg_rx

PATCH Applied Lv Yunlong 3 participants 3 messages Mar 29, 2021 – Mar 30, 2021

Subsystems (5)
lore
Share & tools
lore

Lv Yunlong

author
#0 lore raw

PATCH 1/1 ethernet/netronome/nfp: Fix a use after free in nfp_bpf_ctrl_msg_rx

In nfp_bpf_ctrl_msg_rx, if
nfp_ccm_get_type(skb) == NFP_CCM_TYPE_BPF_BPF_EVENT is true, the skb will be freed. But the skb is still used by nfp_ccm_rx(&bpf->ccm, skb).

My patch adds a return when the skb was freed.

Fixes bcf0cafab44fd ("nfp: split out common control message handling code")
---
 drivers/net/ethernet/netronome/nfp/bpf/cmsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c +1 -0
index 0e2db6ea79e9..2ec62c8d86e1 100644
@@ -454,6 +454,7 @@ void nfp_bpf_ctrl_msg_rx(struct nfp_app *app, struct sk_buff *skb)
 			dev_consume_skb_any(skb);
 		else
 			dev_kfree_skb_any(skb);
+		return;
 	}
 
 	nfp_ccm_rx(&bpf->ccm, skb);
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Mon, 29 Mar 2021 04:50:02 -0700 Lv Yunlong wrote:

In nfp_bpf_ctrl_msg_rx, if
nfp_ccm_get_type(skb) == NFP_CCM_TYPE_BPF_BPF_EVENT is true, the skb will be freed. But the skb is still used by nfp_ccm_rx(&bpf->ccm, skb).

My patch adds a return when the skb was freed.

Fixes bcf0cafab44fd ("nfp: split out common control message handling code")
#2 lore raw
In reply to Lv Yunlong
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 10 lines · On Mon, 29 Mar 2021 04:50:02 -0700 you wrote:

In nfp_bpf_ctrl_msg_rx, if
nfp_ccm_get_type(skb) == NFP_CCM_TYPE_BPF_BPF_EVENT is true, the skb will be freed. But the skb is still used by nfp_ccm_rx(&bpf->ccm, skb).

My patch adds a return when the skb was freed.

Fixes bcf0cafab44fd ("nfp: split out common control message handling code")

[...]

Here is the summary with links:
- ethernet/netronome/nfp: Fix a use after free in nfp_bpf_ctrl_msg_rx

    https://git.kernel.org/netdev/net/c/6e5a03bcba44

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