Skip to content

Commit 7397906

Browse files
committed
prlimit: do_prlimit needs to have a speculation check
do_prlimit() adds the user-controlled resource value to a pointer that will subsequently be dereferenced. In order to help prevent this codepath from being used as a spectre "gadget" a barrier needs to be added after checking the range. Reported-by: Jordy Zomer <jordyzomer@google.com> Tested-by: Jordy Zomer <jordyzomer@google.com> Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9be182d commit 7397906

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/sys.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,8 @@ static int do_prlimit(struct task_struct *tsk, unsigned int resource,
14421442

14431443
if (resource >= RLIM_NLIMITS)
14441444
return -EINVAL;
1445+
resource = array_index_nospec(resource, RLIM_NLIMITS);
1446+
14451447
if (new_rlim) {
14461448
if (new_rlim->rlim_cur > new_rlim->rlim_max)
14471449
return -EINVAL;

0 commit comments

Comments
 (0)