Skip to content

Commit 45c8178

Browse files
jeremyclinegregkh
authored andcommitted
net: socket: fix potential spectre v1 gadget in socketcall
commit c8e8cd5 upstream. 'call' is a user-controlled value, so sanitize the array index after the bounds check to avoid speculating past the bounds of the 'nargs' array. Found with the help of Smatch: net/socket.c:2508 __do_sys_socketcall() warn: potential spectre issue 'nargs' [r] (local cap) Cc: Josh Poimboeuf <[email protected]> Cc: [email protected] Signed-off-by: Jeremy Cline <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c8159f9 commit 45c8178

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/socket.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include <linux/magic.h>
9090
#include <linux/slab.h>
9191
#include <linux/xattr.h>
92+
#include <linux/nospec.h>
9293

9394
#include <linux/uaccess.h>
9495
#include <asm/unistd.h>
@@ -2443,6 +2444,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
24432444

24442445
if (call < 1 || call > SYS_SENDMMSG)
24452446
return -EINVAL;
2447+
call = array_index_nospec(call, SYS_SENDMMSG + 1);
24462448

24472449
len = nargs[call];
24482450
if (len > sizeof(a))

0 commit comments

Comments
 (0)