Netdev List
 help / color / mirror / Atom feed
* [PATCH net] netdevsim: prevent bad user input in nsim_dev_health_break_write()
@ 2024-12-13 17:25 Eric Dumazet
  2024-12-13 17:49 ` Joe Damato
  2024-12-15 21:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-12-13 17:25 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, Simon Horman, eric.dumazet, Eric Dumazet,
	syzbot+ea40e4294e58b0292f74, Jiri Pirko

If either a zero count or a large one is provided, kernel can crash.

Fixes: 82c93a87bf8b ("netdevsim: implement couple of testing devlink health reporters")
Reported-by: syzbot+ea40e4294e58b0292f74@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/675c6862.050a0220.37aaf.00b1.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jiri Pirko <jiri@nvidia.com>
---
 drivers/net/netdevsim/health.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
index 70e8bdf34be900f744e821fb237641a27bb71a7b..688f05316b5e109fc84222476023f3f1f078cf28 100644
--- a/drivers/net/netdevsim/health.c
+++ b/drivers/net/netdevsim/health.c
@@ -149,6 +149,8 @@ static ssize_t nsim_dev_health_break_write(struct file *file,
 	char *break_msg;
 	int err;
 
+	if (count == 0 || count > PAGE_SIZE)
+		return -EINVAL;
 	break_msg = memdup_user_nul(data, count);
 	if (IS_ERR(break_msg))
 		return PTR_ERR(break_msg);
-- 
2.47.1.613.gc27f4b7a9f-goog


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

* Re: [PATCH net] netdevsim: prevent bad user input in nsim_dev_health_break_write()
  2024-12-13 17:25 [PATCH net] netdevsim: prevent bad user input in nsim_dev_health_break_write() Eric Dumazet
@ 2024-12-13 17:49 ` Joe Damato
  2024-12-15 21:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Damato @ 2024-12-13 17:49 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
	Simon Horman, eric.dumazet, syzbot+ea40e4294e58b0292f74,
	Jiri Pirko

On Fri, Dec 13, 2024 at 05:25:18PM +0000, Eric Dumazet wrote:
> If either a zero count or a large one is provided, kernel can crash.
> 
> Fixes: 82c93a87bf8b ("netdevsim: implement couple of testing devlink health reporters")
> Reported-by: syzbot+ea40e4294e58b0292f74@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/675c6862.050a0220.37aaf.00b1.GAE@google.com/T/#u
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jiri Pirko <jiri@nvidia.com>
> ---
>  drivers/net/netdevsim/health.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
> index 70e8bdf34be900f744e821fb237641a27bb71a7b..688f05316b5e109fc84222476023f3f1f078cf28 100644
> --- a/drivers/net/netdevsim/health.c
> +++ b/drivers/net/netdevsim/health.c
> @@ -149,6 +149,8 @@ static ssize_t nsim_dev_health_break_write(struct file *file,
>  	char *break_msg;
>  	int err;
>  
> +	if (count == 0 || count > PAGE_SIZE)
> +		return -EINVAL;
>  	break_msg = memdup_user_nul(data, count);
>  	if (IS_ERR(break_msg))
>  		return PTR_ERR(break_msg);
> -- 

Reviewed-by: Joe Damato <jdamato@fastly.com>

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

* Re: [PATCH net] netdevsim: prevent bad user input in nsim_dev_health_break_write()
  2024-12-13 17:25 [PATCH net] netdevsim: prevent bad user input in nsim_dev_health_break_write() Eric Dumazet
  2024-12-13 17:49 ` Joe Damato
@ 2024-12-15 21:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-15 21:30 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, netdev, horms, eric.dumazet,
	syzbot+ea40e4294e58b0292f74, jiri

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 13 Dec 2024 17:25:18 +0000 you wrote:
> If either a zero count or a large one is provided, kernel can crash.
> 
> Fixes: 82c93a87bf8b ("netdevsim: implement couple of testing devlink health reporters")
> Reported-by: syzbot+ea40e4294e58b0292f74@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/675c6862.050a0220.37aaf.00b1.GAE@google.com/T/#u
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jiri Pirko <jiri@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net] netdevsim: prevent bad user input in nsim_dev_health_break_write()
    https://git.kernel.org/netdev/net/c/ee76746387f6

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] 3+ messages in thread

end of thread, other threads:[~2024-12-15 21:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 17:25 [PATCH net] netdevsim: prevent bad user input in nsim_dev_health_break_write() Eric Dumazet
2024-12-13 17:49 ` Joe Damato
2024-12-15 21:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox