Commit 73979060 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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: default avatarJordy Zomer <jordyzomer@google.com>
Tested-by: default avatarJordy Zomer <jordyzomer@google.com>
Suggested-by: default avatarLinus Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9be182da
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1442,6 +1442,8 @@ static int do_prlimit(struct task_struct *tsk, unsigned int resource,

	if (resource >= RLIM_NLIMITS)
		return -EINVAL;
	resource = array_index_nospec(resource, RLIM_NLIMITS);

	if (new_rlim) {
		if (new_rlim->rlim_cur > new_rlim->rlim_max)
			return -EINVAL;