Skip to content

Commit 6510c78

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: process: fix kernel info leakage
thread_struct's s[12] may contain random kernel memory content, which may be finally leaked to userspace. This is a security hole. Fix it by clearing the s[12] array in thread_struct when fork. As for kthread case, it's better to clear the s[12] array as well. Fixes: 7db91e5 ("RISC-V: Task implementation") Signed-off-by: Jisheng Zhang <[email protected]> Tested-by: Guo Ren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Guo Ren <[email protected]> Link: https://lore.kernel.org/r/CAJF2gTSdVyAaM12T%[email protected]/ Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 8bc8824 commit 6510c78

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/riscv/kernel/process.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
164164
unsigned long tls = args->tls;
165165
struct pt_regs *childregs = task_pt_regs(p);
166166

167+
memset(&p->thread.s, 0, sizeof(p->thread.s));
168+
167169
/* p->thread holds context to be restored by __switch_to() */
168170
if (unlikely(args->fn)) {
169171
/* Kernel thread */

0 commit comments

Comments
 (0)