Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp287402pxb; Thu, 31 Mar 2022 05:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMFTArVCHRZV4poiP4lJFes2vDLdkXAbEbhUtVTVQ27dAV0KItwMXiC6EVSG/M1MQRcB2H X-Received: by 2002:a17:906:c344:b0:6b4:c768:4a9a with SMTP id ci4-20020a170906c34400b006b4c7684a9amr4792651ejb.151.1648730070302; Thu, 31 Mar 2022 05:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648730070; cv=none; d=google.com; s=arc-20160816; b=UpmywhpuANhMg3HHaEWmXkxFl9OGKhul6fkmK1l1SGq6i6EshLxAMv5+jwZFjTab9Q CjEIltS8awxG9O0nifIfhykC43eZZjcJtPpO8OpIW9c2vlP8V/AtqkYPiAtnZlYO+7pl 8Xx6ypu8fNqSx3r4TvLsN6VCt7vb6NRoNsN2HhO+1s6Rrv3R6l17BbjwmQrg+JZuewIe gTINsv1nmhcBXwAtMjh8t9YO8ys3e/UFYq6bzV9I5AWxKq8v3KvP+QvgUwFkxBzrXuRS ITEH2+M1zDMC09n0rML3t506mRFs2VjfvhN7rsTQKeRZRFX9JZFEqW/0/sBaIgl63E+M jFnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=OwE2qrPREXBAZJLUije7kgcRezVwOSsDx8NrnFkFpuk=; b=FI/BVxxD/tmDVmbpeL2zbz2QkFu17rXuS83H57PSiQpgDIPWbiUZSJ65GF/y1rNPWW tqcu0KdoG4eViE2yd9gTmDcbbxxqbPT/zFXYe02qKfrgC+24RQnIEJ820XF0qUYheRaH ztewNnF8e4ltF27X99hf9m4I9Ym+UEfGurxrZKzgizpPbZBWxILdPHL55WIBMSs1wdYh jOOqcigf9/C2D0PiNvBReXhersOkCZNO0Ol+w2aUM7zpxGNTFdWqtFC7wFb+9vqUwoXH leoBmJw4ECNyXnMBoE0sysiVXwnfOix+Tf7YrMkSbAno8XmwjL4wIPzVrW8wMH4tiH7U SvBw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020aa7d453000000b00418c2b5bd43si23707640edr.37.2022.03.31.05.34.03; Thu, 31 Mar 2022 05:34: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbiCaJxu (ORCPT + 99 others); Thu, 31 Mar 2022 05:53:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbiCaJxt (ORCPT ); Thu, 31 Mar 2022 05:53:49 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69752016BC for ; Thu, 31 Mar 2022 02:52:01 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id D117D68AA6; Thu, 31 Mar 2022 11:51:55 +0200 (CEST) Date: Thu, 31 Mar 2022 11:51:55 +0200 From: Christoph Hellwig To: Heiko Stuebner Cc: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, wefu@redhat.com, liush@allwinnertech.com, guoren@kernel.org, atishp@atishpatra.org, anup@brainfault.org, drew@beagleboard.org, hch@lst.de, arnd@arndb.de, wens@csie.org, maxime@cerno.tech, gfavor@ventanamicro.com, andrea.mondelli@huawei.com, behrensj@mit.edu, xinhaoqu@huawei.com, mick@ics.forth.gr, allen.baum@esperantotech.com, jscheid@ventanamicro.com, rtrauben@gmail.com, samuel@sholland.org, cmuellner@linux.com, philipp.tomsich@vrull.eu, Atish Patra Subject: Re: [PATCH v8 01/14] riscv: prevent null-pointer dereference with sbi_remote_fence_i Message-ID: <20220331095155.GA23422@lst.de> References: <20220324000710.575331-1-heiko@sntech.de> <20220324000710.575331-2-heiko@sntech.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220324000710.575331-2-heiko@sntech.de> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,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 Thu, Mar 24, 2022 at 01:06:57AM +0100, Heiko Stuebner wrote: > The callback used inside sbi_remote_fence_i is set at sbi probe time > to the needed variant. Before that it is a NULL pointer. > > Some users like the flush_icache_*() functions suggest a generic > functionality, that doesn't depend on a specific boot-stage but > uses sbi_remote_fence_i as one option to flush other cpu cores. > > So they definitely shouldn't run into null-pointer dereference > issues when called "too early" during boot. > > So introduce an empty function to be the standard for the __sbi_rfence > function pointer until sbi_init has run. > > Users of sbi_remote_fence_i will have separate code for the local > cpu and sbi_init() is called before other cpus are brought up. > So there are no other cpus present at the time when the issue > might happen. I don't really understand this changelog. If flush_icache_* or other routines using SBI calls are called too early they won't do what they are asked to do, which implies a bug in the code. So crashing absolutely is the right thing to do here as we don't really have any other error reporting method available. So unless I'm totally misunderstanding what you are saying here: Nacked-by: Christoph Hellwig