[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231107121837.3759358-15-sashal@kernel.org>
Date: Tue, 7 Nov 2023 07:16:17 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Philipp Stanner <pstanner@...hat.com>,
David Airlie <airlied@...hat.com>, Baoquan He <bhe@...hat.com>,
Kees Cook <keescook@...omium.org>,
Zack Rusin <zackr@...are.com>, Sasha Levin <sashal@...nel.org>,
ebiederm@...ssion.com, kexec@...ts.infradead.org
Subject: [PATCH AUTOSEL 6.6 15/40] kernel: kexec: copy user-array safely
From: Philipp Stanner <pstanner@...hat.com>
[ Upstream commit 569c8d82f95eb5993c84fb61a649a9c4ddd208b3 ]
Currently, there is no overflow-check with memdup_user().
Use the new function memdup_array_user() instead of memdup_user() for
duplicating the user-space array safely.
Suggested-by: David Airlie <airlied@...hat.com>
Signed-off-by: Philipp Stanner <pstanner@...hat.com>
Acked-by: Baoquan He <bhe@...hat.com>
Reviewed-by: Kees Cook <keescook@...omium.org>
Reviewed-by: Zack Rusin <zackr@...are.com>
Signed-off-by: Dave Airlie <airlied@...hat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230920123612.16914-4-pstanner@redhat.com
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
kernel/kexec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 107f355eac101..8f35a5a42af85 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -247,7 +247,7 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT))
return -EINVAL;
- ksegments = memdup_user(segments, nr_segments * sizeof(ksegments[0]));
+ ksegments = memdup_array_user(segments, nr_segments, sizeof(ksegments[0]));
if (IS_ERR(ksegments))
return PTR_ERR(ksegments);
--
2.42.0
Powered by blists - more mailing lists