Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4837120iog; Wed, 22 Jun 2022 06:51:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s8beV3QRN5sVQMf4BugTsNB01Dc5naBkgs+YZnhW9nV4U8Dfxu+nYaGsue3BwRBNJAHVZD X-Received: by 2002:aa7:870b:0:b0:522:c223:5c5e with SMTP id b11-20020aa7870b000000b00522c2235c5emr35421833pfo.6.1655905890183; Wed, 22 Jun 2022 06:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655905890; cv=none; d=google.com; s=arc-20160816; b=vk0zc4UBWuDd41O7TmINVtyuHLicXo/T7iZlv8tYRfSFRsNRv215f4gG0iDRqFVd1g TrKwMiIXLu7f4EjlBzE+2BLnry3F5UnBNO50i6VWhuWwsD03qzQLu6lnqCsNCWo/XsWu 4cGgUam8s66V0lDklZuzW7ZmzJZaRZgwVYQJUukoVnhJRa3k+qy5qKow2BcbpmYCYx/y UPCvuMZz0qC4XeA6XZJ7iXIVCgkbb5gYiUmVeHywqoO3tPNFcqp1gZnsLvQ2PGptk1dq fk+aWEunXLd9o6n3McqSJktFWkc5kxswz/E/s5L3RE/Pc0sAaP2WD6N70WIRebwXI2mw tg9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature; bh=Px+iK29VfYgE6xtwDuv2GVO96Knmh6JSD7fS/Fzcz7U=; b=PyHjXM5YisU4nCjKI0ooQDKK8mgNecV3CXtaMq4cMktE3wWVq9cW5AVtbw+adn20ii bPZx+cFjy03DwOKv+A7Mt0OGUKFrlCvNeiS8Tesb0ZJWnzgLgcV8ScwpeGTeTJwc/Xm9 Yg00gDPjx/flfBJHuaKKewIqRF/oWTbUkMoiIXFbL3uN0y+Em+tKoBd3bWfVz+XBSuSk UeJAbEZ0A9AOLFDLYT5N8lXju/5wpQrgbaGN0AWWwDrsFAWMGe+j60l0A6PwxEpq/kjn 2izukCw6W+13inqZl1KXzvvPKRk62YVS+bdFziR23vk7G7fMbd+BTBo9YRZM1QEbWqrH vbJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zk0iqekn; 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 q3-20020a170902bd8300b001620da7e3bfsi16995088pls.185.2022.06.22.06.51.17; Wed, 22 Jun 2022 06:51:30 -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=Zk0iqekn; 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 S1357515AbiFVNuY (ORCPT + 99 others); Wed, 22 Jun 2022 09:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357456AbiFVNuV (ORCPT ); Wed, 22 Jun 2022 09:50:21 -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 04D591F623 for ; Wed, 22 Jun 2022 06:50:21 -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 B0FB8B81EF0 for ; Wed, 22 Jun 2022 13:50:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6588CC34114; Wed, 22 Jun 2022 13:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655905818; bh=ya9bqHBDJvc1AcWbARdp9qu/ISmbWxRfpR+xvLAIZLs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Zk0iqeknSgIo6vL+FZoYBf3foeVOgFqPWHcUK+jo8KELqfsFT/V1RYIDYaVjMUILe QCXkdx5C49M8TRxA+EFJu9Xf3upzGlYRuI07ibHd9nSuP5Q2+vjBHWCOxQ61Pr1x2M CohAIgEHJTCz5xKzkoJwacpMOPdvyDPmC6+8GMpVB80c2iqzlDXfk5UV94QVH9l2y0 muFQrqcC6rIepNuGy3KANVqGdjQ9DEcg9mNovUcytRdKk8GFWonqN4qWdiMfsOXlok Cat6tUdy1exaqz7NuJyIx9o35xS87HEV1A6I7HZHxhJ2uRdETmswPv3Xx2ajuBMt9A bF8dq8xRVln5A== Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o40kK-002Jtk-4F; Wed, 22 Jun 2022 14:50:16 +0100 MIME-Version: 1.0 Date: Wed, 22 Jun 2022 14:50:15 +0100 From: Marc Zyngier To: Tetsuo Handa Cc: Russell King , Tony Lindgren , LKML , Linux ARM Subject: Re: [PATCH] ARM: spectre-v2: fix smp_processor_id() warning In-Reply-To: <795c9463-452e-bf64-1cc0-c318ccecb1da@I-love.SAKURA.ne.jp> References: <795c9463-452e-bf64-1cc0-c318ccecb1da@I-love.SAKURA.ne.jp> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: maz@kernel.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: penguin-kernel@i-love.sakura.ne.jp, linux@armlinux.org.uk, tony@atomide.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.7 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,T_SCC_BODY_TEXT_LINE 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 2022-06-22 07:49, Tetsuo Handa wrote: > syzbot complains smp_processor_id() from harden_branch_predictor() > from page fault path [1]. Explicitly disable preemption and use > raw_smp_processor_id(). > > Link: https://syzkaller.appspot.com/bug?extid=a7ee43e564223f195c84 [1] > Reported-by: syzbot > > Fixes: f5fe12b1eaee220c ("ARM: spectre-v2: harden user aborts in kernel > space") > Signed-off-by: Tetsuo Handa > --- > This patch is completely untested. > > arch/arm/include/asm/system_misc.h | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/include/asm/system_misc.h > b/arch/arm/include/asm/system_misc.h > index 98b37340376b..a92446769acd 100644 > --- a/arch/arm/include/asm/system_misc.h > +++ b/arch/arm/include/asm/system_misc.h > @@ -20,8 +20,11 @@ typedef void (*harden_branch_predictor_fn_t)(void); > DECLARE_PER_CPU(harden_branch_predictor_fn_t, > harden_branch_predictor_fn); > static inline void harden_branch_predictor(void) > { > - harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn, > - smp_processor_id()); > + harden_branch_predictor_fn_t fn; > + > + preempt_disable_notrace(); > + fn = per_cpu(harden_branch_predictor_fn, raw_smp_processor_id()); > + preempt_enable_no_resched_notrace(); > if (fn) > fn(); > } I don't think that's required. harden_branch_predictor() is always called on the fault path, from __do_user_fault(), and that's always non-preemptible. My hunch is that we're missing some tracking that indicates to the kernel that we're already non-preemptible by virtue of being in an exception handler. Russell, what do you think? M. -- Jazz is not dead. It just smells funny...