Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp729191qtx; Mon, 31 Oct 2022 12:25:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7G4qH0Mr/DnpuXAC+diXBAvVIDwUbt0nY1e2mJO4VqYP+QYwyXPGsfcFe1lYbdJoV/aKYh X-Received: by 2002:a05:6402:847:b0:45b:d50c:b9aa with SMTP id b7-20020a056402084700b0045bd50cb9aamr15120508edz.289.1667244344336; Mon, 31 Oct 2022 12:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667244344; cv=none; d=google.com; s=arc-20160816; b=OhC7HPdZEwtVPGLUrhaiZ4JPecmh7jj0lnxMeNapxc3zuaIDXVlZeGb4hFPSR2CV8X J4TK1aU5C1Ya8Cc3vLrsef84+QnU378/oKZmcYU3d9bW/rg56MGByr5mFxFvTZbrCtl9 V35vCkqgxwWWj8jM0VLKreMct4Jkfhz30A5jO5WnB+xjj/4WAE7skm7oaMw+CHcbAnYQ OdckrrNQdAxbOXhhhEspFm06qVSesbAxmr0iuE9BXMmdWBQ6wFHr3mP2amvXQb3LvHBx DZUy1syH873PllEf6uQSS/1yXXybOpnxJ+ld4MW/WH8XD//6Ep1+ZakmNlFmN+5Czwld N3BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RxggAqCY3SaBstkiqitb9EGahTzZl2UNvu0K/P/XJpA=; b=id1P00/+630mHsUNprwO+j2GB4QQ80Xvr6PIFNSHuptf7nEcZ2/kXfdMVDQQa8f97J TwZhLSNYvsvMySPlr8sE1BgrYC7lbrbelCL06zmkNxk2/F6VjM5RnjnabVC/wn5hZGjt jxtRYDNZYzr4PmlBV0LdfnSQ3Xuz09tK4rNIi8N9FiZpjJ03k64eiTkTDdrzB7CI21GW Vs4nSJJEbPRaWLzV7MvEper0H8eFRO4IOPIcu/IqOsbSElAQ0T+kmz5GEMPAvUjakpCL XQeiZO19ufFMynjLc7kQosu0/CdDhgdw4y/ZmuxKP9N6c2IFrNV+93Lj/2Lo3HyhYUX9 CigA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xixhbcpm; 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 dr12-20020a170907720c00b0073de493b83esi10888560ejc.147.2022.10.31.12.25.20; Mon, 31 Oct 2022 12:25:44 -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=Xixhbcpm; 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 S229967AbiJaTOO (ORCPT + 98 others); Mon, 31 Oct 2022 15:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbiJaTON (ORCPT ); Mon, 31 Oct 2022 15:14:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B02C120BD for ; Mon, 31 Oct 2022 12:14:12 -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 dfw.source.kernel.org (Postfix) with ESMTPS id DAFCB61418 for ; Mon, 31 Oct 2022 19:14:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1AB9C433C1; Mon, 31 Oct 2022 19:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667243651; bh=80lqoPPKDQ+glCPrCeg2E0gbOPazZmUenJWu7c2v11s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XixhbcpmCWhV7gKONpioTcsPjwo2dubUfERuxu+IC1URA6AThPGAW1QT8pM76DbZc TuL61Mc0yVscRfNbtfO7fxI2Aeel+eKLGOvfmRdbYLHIGrGTsoeXghxXtjbOvNFzwC u+bMsgr6u06r/u3PMYjW6EHQVf+L+e+vKAE1wkqeIsGMjL0097ckG9WYjbZslkJieL l33yQRsao15+j07391m/ub1t8lg3ZkhsAr8cyy/XYlmfFewsWa3btuFAAmuSZ0dEZJ PWjuZiPd7Kf3jFMP3ArpS0tEdzqiH1qeD/K0zn7t9PONKFzB4oqXhYVD+OkAlzW5/a TCEYD90sRgRWA== Date: Mon, 31 Oct 2022 19:14:06 +0000 From: Conor Dooley To: Jisheng Zhang Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: process: fix kernel info leakage Message-ID: References: <20221029113450.4027-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221029113450.4027-1-jszhang@kernel.org> X-Spam-Status: No, score=-8.1 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 07:34:50PM +0800, 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 Should this not be carrying a R-b from Guo Ren from that series? https://lore.kernel.org/linux-riscv/CAJF2gTSdVyAaM12T+7kXAdRPGS4VyuO08X1c7paE-n4Fr8OtRA@mail.gmail.com/ > > 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)); > + > /* p->thread holds context to be restored by __switch_to() */ > if (unlikely(args->fn)) { > /* Kernel thread */ > -- > 2.37.2 >