Skip to content

Commit ee76746

Browse files
edumazetkuba-moo
authored andcommitted
netdevsim: prevent bad user input in nsim_dev_health_break_write()
If either a zero count or a large one is provided, kernel can crash. Fixes: 82c93a8 ("netdevsim: implement couple of testing devlink health reporters") Reported-by: [email protected] Closes: https://lore.kernel.org/netdev/[email protected]/T/#u Signed-off-by: Eric Dumazet <[email protected]> Cc: Jiri Pirko <[email protected]> Reviewed-by: Joe Damato <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2d5df3a commit ee76746

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/netdevsim/health.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static ssize_t nsim_dev_health_break_write(struct file *file,
149149
char *break_msg;
150150
int err;
151151

152+
if (count == 0 || count > PAGE_SIZE)
153+
return -EINVAL;
152154
break_msg = memdup_user_nul(data, count);
153155
if (IS_ERR(break_msg))
154156
return PTR_ERR(break_msg);

0 commit comments

Comments
 (0)