Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp816619rdg; Wed, 11 Oct 2023 06:27:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW9vBt8u2SZQzHfhCSpDZyVqsP7/R2WZdSCtjSNPkIrkvRknEAQlz6MAFX/3vinJkkM9pL X-Received: by 2002:a17:902:a504:b0:1c3:308b:ecb9 with SMTP id s4-20020a170902a50400b001c3308becb9mr15881306plq.11.1697030858834; Wed, 11 Oct 2023 06:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697030858; cv=none; d=google.com; s=arc-20160816; b=iEdB4gs+vTpLut/+6PA5nUodTJdz9nuKRqbph4ByQq1GETsaBoD/BLNUY9aqOQz0ik T7fwVQ7vfzi1bUekVjF4PS07Br3GK+dgoMsX8YFjocatzYtmb9j1r3Rxy78T1ggvUTR+ KFm6Ri353ZjYSoAVNfZ5KIXeH2r4TmeRkxSM54PpDBELCO/q30HNC4pCHMMamTyXzfkQ khL2aoRvYVcBAWEFjLr9lwn7rCyqM3Uf9AQiwFaWOocHYTaHoOPRpB608cs9W+bFn79t 1dxQNDKUO7mhAZOfxg5CUG3vzKNA4sQSaerVR895NP4esaE/p3bsqlsS/bO0/IxUqig2 VjkQ== 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=eEAKmfl8e3fXJ5jIx1jPPupNKS6g/TnavdOqr7u8H/g=; fh=fLJpdFXMrgkhIFph62k+jGdYXP9DzrA5vOfmQT1EouI=; b=md61ttl10GYW0MtRzDd+uVUmU1dRTHKlJju3f1FD+dO62Ba+R0zBaoQG5Ph1OYBp7I LsBeo6FsXVbWoALp9zP5Xm8FrvBxPdKd/PmHQWsOg73UvIfTE8uEUkwh66aEGyw4fcYa CDvoXCFckyZDg+y+XBkt35dM+o4qLUF9yefgOBw76h+EO0gP9xVDd2KnF0nM16Om/zpN 48aw86GwS82r6gHC/ggFbTJ298FxcqMZUZ2kWSVrifx0fWKV7xfLo0+ZQlPdD3PNA6qg bzx0bvmY3AdN0+CCTFtN1LTqKuCzGNNR3zgy+YmCPxoL+PeKc/9MyXqhz183BTuLN6MA scAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XQ2th9Dp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 20-20020a170902ee5400b001c42b2b02casi14001607plo.174.2023.10.11.06.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XQ2th9Dp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B184080F9BDA; Wed, 11 Oct 2023 06:27:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346859AbjJKN1a (ORCPT + 99 others); Wed, 11 Oct 2023 09:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235025AbjJKN12 (ORCPT ); Wed, 11 Oct 2023 09:27:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8554FA7; Wed, 11 Oct 2023 06:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697030846; x=1728566846; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ZHyLjPxJ1mR4uC3cntVpwvMSEvJUP/rV/lx58B5OooE=; b=XQ2th9DpXbsK+KjyDerDrSAN2kKNrPDhrrsEU8Sp4uSM+LTjgteHTsW/ coY+pthL7Uay2QqFbkLHdY4DnEFxlG0zMGG+ioEMEqN5mWlXhfVYjNT6f w4ikhqiylJ5bxirq8JVEuEdBiOoYlMVXBnSkSh6byQMK00dY63qTwnYqU HzBmnymX4TxTTWeF9CzPMiiunxMLCH/ByOurFwl5L1Fr2J2Oi4TtHG5Lo +W12r7O3QxBnflZKzjt9KphEKgXxFSeQ4WbRD6zrfAb2L7cOdYUAPZWZw aA7Wfw57zN3TMMAMRJT+tuArzOPAYfNJU0AqEcWzSHJQi5CIk/BpO6gK3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3249908" X-IronPort-AV: E=Sophos;i="6.03,216,1694761200"; d="scan'208";a="3249908" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 06:27:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="897624429" X-IronPort-AV: E=Sophos;i="6.03,216,1694761200"; d="scan'208";a="897624429" Received: from laptop-dan-intel.ccr.corp.intel.com (HELO box.shutemov.name) ([10.252.56.166]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 06:25:21 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 29011109FB5; Wed, 11 Oct 2023 16:27:03 +0300 (+03) Date: Wed, 11 Oct 2023 16:27:03 +0300 From: "Kirill A. Shutemov" To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Fei Yang , stable@vger.kernel.org Subject: Re: [PATCHv2] x86/alternatives: Disable KASAN in apply_alternatives() Message-ID: <20231011132703.3evo4ieradgyvgc2@box.shutemov.name> References: <20231011065849.19075-1-kirill.shutemov@linux.intel.com> <20231011074616.GL14330@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231011074616.GL14330@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 06:27:36 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 09:46:16AM +0200, Peter Zijlstra wrote: > On Wed, Oct 11, 2023 at 09:58:49AM +0300, Kirill A. Shutemov wrote: > > Fei has reported that KASAN triggers during apply_alternatives() on > > 5-level paging machine: > > > > Urgh @ KASAN splat, can't we summarize that? What about this? BUG: KASAN: out-of-bounds in rcu_is_watching Read of size 4 at addr ff110003ee6419a0 by task swapper/0/0 ... __asan_load4 rcu_is_watching ? text_poke_early trace_hardirqs_on ? __asan_load4 text_poke_early apply_alternatives ... Is it enough details or I overdid summarization? > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > > index 517ee01503be..b4cc4d7c0825 100644 > > --- a/arch/x86/kernel/alternative.c > > +++ b/arch/x86/kernel/alternative.c > > @@ -403,6 +403,17 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, > > u8 insn_buff[MAX_PATCH_LEN]; > > > > DPRINTK(ALT, "alt table %px, -> %px", start, end); > > + > > + /* > > + * In the case CONFIG_X86_5LEVEL=y, KASAN_SHADOW_START is defined using > > + * cpu_feature_enabled(X86_FEATURE_LA57) and is therefore patched here. > > + * During the process, KASAN becomes confused and triggers > > because of partial LA57 convertion .. > > > + * a false-positive out-of-bound report. > > + * > > + * Disable KASAN until the patching is complete. > > + */ > > + kasan_disable_current(); > > + > > /* /* * In the case CONFIG_X86_5LEVEL=y, KASAN_SHADOW_START is defined using * cpu_feature_enabled(X86_FEATURE_LA57) and is therefore patched here. * During the process, KASAN becomes confused seeing partial LA57 * conversion and triggers a false-positive out-of-bound report. * * Disable KASAN until the patching is complete. */ Looks good? If yes, I will submit v3 with your Ack. -- Kiryl Shutsemau / Kirill A. Shutemov