Skip to contentSkip to conversation

net: ethtool: Fix the panic caused by dev being null when dumping coalesce

PATCH RESEND Applied Heng Qi 3 participants 3 messages Jun 28, 2024 – Jul 1, 2024

Subsystems (3)
lore
Share & tools
lore

Heng Qi

author
#0 lore raw

PATCH RESEND 1/1 net: ethtool: Fix the panic caused by dev being null when dumping coalesce

syzbot reported a general protection fault caused by a null pointer dereference in coalesce_fill_reply(). The issue occurs when req_base->dev is null, leading to an invalid memory access.

This panic occurs if dumping coalesce when no device name is specified.

Fixes f750dfe825b9 ("ethtool: provide customized dim profile management")
Reported-by [email protected]

---
This fix patch is re-sent to next branch instead of net branch because the target commit is in the next branch.

 net/ethtool/coalesce.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/ethtool/coalesce.c +3 -2
index 759b16e3d134..3e18ca1ccc5e 100644
@@ -211,9 +211,9 @@ static int coalesce_fill_reply(struct sk_buff *skb,
 {
 	const struct coalesce_reply_data *data = COALESCE_REPDATA(reply_base);
 	const struct kernel_ethtool_coalesce *kcoal = &data->kernel_coalesce;
-	struct dim_irq_moder *moder = req_base->dev->irq_moder;
 	const struct ethtool_coalesce *coal = &data->coalesce;
 	u32 supported = data->supported_params;
+	struct dim_irq_moder *moder;
 	int ret = 0;
 
 	if (coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_USECS,
@@ -272,9 +272,10 @@ static int coalesce_fill_reply(struct sk_buff *skb,
 			     kcoal->tx_aggr_time_usecs, supported))
 		return -EMSGSIZE;
 
-	if (!moder)
+	if (!req_base->dev || !req_base->dev->irq_moder)
 		return 0;
 
+	moder = req_base->dev->irq_moder;
 	rcu_read_lock();
 	if (moder->profile_flags & DIM_PROFILE_RX) {
 		ret = coalesce_put_profile(skb, ETHTOOL_A_COALESCE_RX_PROFILE,
Signature · 1 line
2.32.0.3.g01195cf9f
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Heng Qi

syzbot reported a general protection fault caused by a null pointer dereference in coalesce_fill_reply(). The issue occurs when req_base->dev is null, leading to an invalid memory access.

This panic occurs if dumping coalesce when no device name is specified.

Quoted 7 lines
Fixes f750dfe825b9 ("ethtool: provide customized dim profile management")
Reported-by [email protected]

---
This fix patch is re-sent to next branch instead of net branch because the target commit is in the next branch.

#2 lore raw
In reply to Heng Qi
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 4 lines · On Fri, 28 Jun 2024 12:40:18 +0800 you wrote:

syzbot reported a general protection fault caused by a null pointer dereference in coalesce_fill_reply(). The issue occurs when req_base->dev is null, leading to an invalid memory access.

Quoted 8 lines

This panic occurs if dumping coalesce when no device name is specified.

Fixes f750dfe825b9 ("ethtool: provide customized dim profile management")
Reported-by [email protected]

[...]

Here is the summary with links:
- [RESEND,net-next] net: ethtool: Fix the panic caused by dev being null when dumping coalesce

    https://git.kernel.org/netdev/net-next/c/74d6529b78f7

You are awesome, thank you!

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