[SRU][Jammy-OEM-5.17/OEM-6.0][PATCH 1/1] prlimit: do_prlimit needs to have a speculation check

Yuxuan Luo yuxuan.luo at canonical.com
Mon Jul 31 14:50:03 UTC 2023


From: Greg Kroah-Hartman <gregkh at linuxfoundation.org>

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 at google.com>
Tested-by: Jordy Zomer <jordyzomer at google.com>
Suggested-by: Linus Torvalds <torvalds at linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry picked from commit 739790605705ddcf18f21782b9c99ad7d53a8c11)
CVE-2023-0458
Signed-off-by: Yuxuan Luo <yuxuan.luo at canonical.com>
---
 kernel/sys.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sys.c b/kernel/sys.c
index 1452780c2aff..dc4857fb1b60 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1454,6 +1454,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.34.1




More information about the kernel-team mailing list