forked from rpms/kernel
46 lines
1.6 KiB
Diff
46 lines
1.6 KiB
Diff
|
From c9e34f92dafffe1fd37ba7ef7fb198002576bea1 Mon Sep 17 00:00:00 2001
|
||
|
From: Nagappan Ramasamy Palaniappan <nagappan.ramasamy.palaniappan@oracle.com>
|
||
|
Date: Wed, 2 Aug 2023 12:54:02 +0000
|
||
|
Subject: [PATCH 2/5] prlimit: do_prlimit needs to have a speculation check
|
||
|
|
||
|
CVE: CVE-2023-0458
|
||
|
|
||
|
commit 739790605705ddcf18f21782b9c99ad7d53a8c11
|
||
|
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||
|
Date: Fri Jan 20 11:03:20 2023 +0100
|
||
|
|
||
|
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>
|
||
|
|
||
|
Signed-off-by: Nagappan Ramasamy Palaniappan <nagappan.ramasamy.palaniappan@oracle.com>
|
||
|
Reviewed-by: Laurence Rochfort <laurence.rochfort@oracle.com>
|
||
|
---
|
||
|
kernel/sys.c | 2 ++
|
||
|
1 file changed, 2 insertions(+)
|
||
|
|
||
|
diff --git a/kernel/sys.c b/kernel/sys.c
|
||
|
index 75852f64d..45480f6f6 100644
|
||
|
--- a/kernel/sys.c
|
||
|
+++ b/kernel/sys.c
|
||
|
@@ -1439,6 +1439,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;
|
||
|
--
|
||
|
2.31.1
|
||
|
|