Skip to content

Commit c8e8cd5

Browse files
jeremyclinedavem330
authored andcommitted
net: socket: fix potential spectre v1 gadget in socketcall
'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]>
1 parent 958b4cd commit c8e8cd5

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>
@@ -2522,6 +2523,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
25222523

25232524
if (call < 1 || call > SYS_SENDMMSG)
25242525
return -EINVAL;
2526+
call = array_index_nospec(call, SYS_SENDMMSG + 1);
25252527

25262528
len = nargs[call];
25272529
if (len > sizeof(a))

0 commit comments

Comments
 (0)