prlimit: do_prlimit needs to have a speculation check
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Jan 2023 10:03:20 +0000 (11:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jan 2023 06:22:44 +0000 (07:22 +0100)
commitf01aefe374d32c4bb1e5fd1e9f931cf77fca621a
treef421db3cf2bc0c6442ac1b0c0d64cb0b14718c40
parent418e2c756d65276237e45456d51d7144a3c1a7a1
prlimit: do_prlimit needs to have a speculation check

commit 739790605705ddcf18f21782b9c99ad7d53a8c11 upstream.

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>
kernel/sys.c