From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1CD67C3DA4A for ; Wed, 14 Aug 2024 16:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jpJ/lXwLiU5uwM8jZ3xxZHUwGBtUc0QUa6MJk4IBKBY=; b=kJTNeZuFaMnVe3lxfmVmKhaLXm hVVpjnj/u+XFuZpMsjQoEG3Bk5ZSv/Ky6kRP9fo3HqVKk4qN6ZiD+2fPrCbooX3YkHwoUNxw/ieHA 4aMWTE5i1YnaOTQpW9CKfgoyCArZihqxBM9UQDMEpHXR7BxiszsoBntRqPXZtl73vKhQ5VwMiLku9 a3AvsI7MioEK6bKXNM1tL99lbBgB3KfA57HUKanfJ9cxclR6W+mLMZ+KoHfIvHlM/RPi71t3m25UH 59JIW6/ZUy2jjxSDZKHJvy8YLzKf5G/S9Xi97iKrdr+wbOFDV3c6rLvYT8WN1nUK+1Tm5SaH5fhnI OPTa5uoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seGiv-00000007dPY-007n; Wed, 14 Aug 2024 16:19:45 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seGiH-00000007dJ9-3Fz4 for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 16:19:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 41B10CE1A30; Wed, 14 Aug 2024 16:19:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A4F4C4AF0D; Wed, 14 Aug 2024 16:18:58 +0000 (UTC) Date: Wed, 14 Aug 2024 17:18:56 +0100 From: Catalin Marinas To: Samuel Holland Cc: linux-arm-kernel@lists.infradead.org, Andrew Morton , Andrey Konovalov , Ard Biesheuvel , Douglas Anderson , Frederic Weisbecker , James Morse , Jonathan Cameron , Mark Rutland , Puranjay Mohan , "Russell King (Oracle)" , Ryo Takakura , Shaoqin Huang , Stephen Boyd , Thomas Gleixner , Will Deacon , linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: Fix KASAN random tag seed initialization Message-ID: References: <20240814091005.969756-1-samuel.holland@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240814091005.969756-1-samuel.holland@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_091906_007260_D0DB4C9F X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 14, 2024 at 02:09:53AM -0700, Samuel Holland wrote: > Currently, kasan_init_sw_tags() is called before setup_per_cpu_areas(), > so per_cpu(prng_state, cpu) accesses the same address regardless of the > value of "cpu", and the same seed value gets copied to the percpu area > for every CPU. Fix this by moving the call to smp_prepare_boot_cpu(), > which is the first architecture hook after setup_per_cpu_areas(). Even with the fix, given the lower resolution of get_cycles(), there's a good chance that we still have the same seed on all CPUs. If we want separate seeds, a better bet would be to initialise each CPU separately via the secondary_start_kernel() path. I'll let the KASAN people comment on whether that's important. -- Catalin