Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp1120619rwj; Sat, 29 Oct 2022 17:19:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66k2RniIlG/7sKc7buS9+oB3cXuQutQ1YoSVbQfnGhA1tX1XY8jRVnUMTgqKkArjYyNpeM X-Received: by 2002:a63:e04:0:b0:46f:75bc:8bec with SMTP id d4-20020a630e04000000b0046f75bc8becmr5999488pgl.559.1667089179497; Sat, 29 Oct 2022 17:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089179; cv=none; d=google.com; s=arc-20160816; b=islcDTiFPxrhZqRhj52rJRxplTc3oqo2d44zjPlSvgrJ4mZlYSkDizAfsnrglbJgpE 0HOZsq+3zGuDzyYMtKP5QBYXHD/GTtIFr6h24PPkguEjsc6mRBvhVB0/JA/Y4Nc5PF34 SA1TcDnOKvmo8Li031l0mVU2onF7YC4tVO8gMDEij9Cvz/+lcoJ7R9XBufMBRX3RNQil o5QJHzHGfHdDHA+lx3XwZo0n9+Ka2vN3oO9fWPdOxVHBgvj8fDBX7hboOnsHEVuWcI+A j3HGmEDf0SzQ40GmNIYI6ioRABF2zuTEjGyP5tFAVYKkeYZNgwLzCnP1FDG3NSdjC+6Q JmmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GG1+XXVxL2fl1OgKvjy7zLJvfUfUcYO+YMNkopreGOw=; b=jzSw/aknboP/PqVm6/GXquI0mMHv6WvPqhgcWjhPAMo6hvzsLo6FKaONuqbRsHw9pZ klcXLJfZOcMsbfZWXwM9ZuYLv3QgUmbRdt3CPq525GVFZZ5NU1342He+rZpQZZUeYvKp kT4pm4a3JKX0CTv8XHe1YkiCh2HLp1NXkAxjemAMYw6YFk888BzDpcG4dBULF543sqWY 61fVmYNJzcGz1PSRE6b0VOX/zx6h+P9QNQ/QnwFSvwbbcqMtQpb2ZUohylDFyGrP/hNM uY5cHA/4bT4JsqROqT9SkbyY6x6FgGsvRBWe1XHuJDDjAY0VRBnXPimTmoj+ojmjWvyD x8ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R67YY1Ga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a170903111200b001869e6efb8asi4306994plh.59.2022.10.29.17.19.27; Sat, 29 Oct 2022 17:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R67YY1Ga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbiJ3ADv (ORCPT + 99 others); Sat, 29 Oct 2022 20:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiJ3ADt (ORCPT ); Sat, 29 Oct 2022 20:03:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 214BE18376 for ; Sat, 29 Oct 2022 17:03:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C3100B80D79 for ; Sun, 30 Oct 2022 00:03:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75CEBC43140 for ; Sun, 30 Oct 2022 00:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667088226; bh=N8BoS/M4L7MN742ZawYJ9PH0fLN3a+oJBqMQwatxgWA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=R67YY1Gav64QhlE6uoqvYWw7WVMiCUgujQzsj0WitIB76bL2THVR2Vk6/2TpfFrqa puQfQpLcRiO3N2pF7tAfk4IAU/1cXWQR5cDL3iptfwWThnbaPT4nb6iZLz5Khh33WB fQEaxIlijK4X5wAnptBRF85szuartiKcMyeW7lVyLwBByFPllysiXZOC1jwLZG2o1G Cxw7hNLJ6YchlUK1AUfVbWGHWGTrq+V88iMgPdICTr+UwrA+XRbRJzLHE4ebpXnAym gqNtA/y9epgwGn/g5AhbpooiKl0nln5US2i5eTPUH7AyK5dVxNYSFEnM9sUTQh31wI FdGdWtT10S7XA== Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-13ba9a4430cso10160802fac.11 for ; Sat, 29 Oct 2022 17:03:46 -0700 (PDT) X-Gm-Message-State: ACrzQf2SSDbUXRBkhnGY0YCd1o/YtcHtzaVLoU0+WXkkNR+/1qsQP6YP 4ayXPFCsPIdsvpTKujRmvv4op8G3aWTVA8OToiU= X-Received: by 2002:a05:6870:64a1:b0:13c:d09d:79f9 with SMTP id cz33-20020a05687064a100b0013cd09d79f9mr830568oab.112.1667088225682; Sat, 29 Oct 2022 17:03:45 -0700 (PDT) MIME-Version: 1.0 References: <20221029113450.4027-1-jszhang@kernel.org> In-Reply-To: <20221029113450.4027-1-jszhang@kernel.org> From: Guo Ren Date: Sun, 30 Oct 2022 08:03:33 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] riscv: process: fix kernel info leakage To: Jisheng Zhang Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 29, 2022 at 7:44 PM Jisheng Zhang wrote: > > 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: 7db91e57a0ac ("RISC-V: Task implementation") > Signed-off-by: Jisheng Zhang > --- > > Previously, it's one of the series of "riscv: entry: further clean up > and VMAP_STACK fix". This is a fix, so I move it out of the series and > send it separately > > arch/riscv/kernel/process.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c > index ceb9ebab6558..52002d54b163 100644 > --- a/arch/riscv/kernel/process.c > +++ b/arch/riscv/kernel/process.c > @@ -164,6 +164,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) > unsigned long tls = args->tls; > struct pt_regs *childregs = task_pt_regs(p); > > + memset(&p->thread.s, 0, sizeof(p->thread.s)); Tested-by: Guo Ren > + > /* p->thread holds context to be restored by __switch_to() */ > if (unlikely(args->fn)) { > /* Kernel thread */ > -- > 2.37.2 > -- Best Regards Guo Ren