Skip to content

Commit baaa0eb

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 e8445da commit baaa0eb

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>
@@ -2526,6 +2527,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
25262527

25272528
if (call < 1 || call > SYS_SENDMMSG)
25282529
return -EINVAL;
2530+
call = array_index_nospec(call, SYS_SENDMMSG + 1);
25292531

25302532
len = nargs[call];
25312533
if (len > sizeof(a))

0 commit comments

Comments
 (0)