Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2362952rdb; Tue, 10 Oct 2023 01:21:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqS3VbEGK3tA/riIswqxphLSRQpBEGubDBWQ1pa05Xw+gRx7bNRmTI2APJNWZjCod0/CAj X-Received: by 2002:a05:6a21:3284:b0:16b:79b3:222b with SMTP id yt4-20020a056a21328400b0016b79b3222bmr15033506pzb.34.1696926109278; Tue, 10 Oct 2023 01:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696926109; cv=none; d=google.com; s=arc-20160816; b=r7U0vilRykjsRBgT/4NxpJKrU7ZHu4u7d/mqeHjQDlJCewQrO4tNl+24TtDytUB/QI W9TIaJ+tVFeqxDvVJeUR+D7UmUhu6OvZtmoNni0k/9dMxwjyslk/VXMHZ1vGuCEXYKgg 3C19B9Ji7LpVSszSZTft3jidVQG9SVWjecoRhYdaY9nIuyB4hLGBcF8qX5onbNkeiM6M UPF3aiJJsd4326kGC4/8mO96TyvFt536ePHmnYl+Aw/pwpV7OX1abCz+NbV3Ls9jPqzr 9GdKgqNWi6TZvZNw++7DLPb0JIIP388Nvb/BOb0iZ0yVPlpjkYCDGGcom06QqgSoaPna 5Crg== 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=E9CMcde7JhHmBwITrfwM1TdYK1kSavxuW5gL57dtmNY=; fh=tMvHKGT1+QcASgZQMJhW3iAjRPPaJkqDzc/tI8OKJZo=; b=zEKg4UFm0rdhWdFt5R9LhYlKie6xI/zXLnG7gA48Ol1dPmY51CESd8roxlLeXzGEy9 0gO1qhvnKybndBG6hG8k25/SGoiK/6mj620nmD2S2P1swbAvCcEEdFuC7fyNyDZRcnfj US/ZA0pwClVicRMfAh96V5y369C4R4PcC8SwTKaNhqayifjAYiVhao7VCcgD9thHFLyo G+LMW0KTiOBkowIYnjnIiUGu/Clu2FEPF+PqRHglVBkIfb806dDavR+a5btg7XGwzy0L G13X4VKU92CI6oIkefIBeP7SjR9r7KWP5JjTKb00x1hg6a02SRg5+zU5N9tAFcwSLyQZ UYSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=YO31Bh3h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k15-20020a056a00134f00b0068e4704fd5bsi9509990pfu.346.2023.10.10.01.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:21:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=YO31Bh3h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id F2CF9805934E; Tue, 10 Oct 2023 01:21:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379473AbjJJIU4 (ORCPT + 99 others); Tue, 10 Oct 2023 04:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442776AbjJJIUd (ORCPT ); Tue, 10 Oct 2023 04:20:33 -0400 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8641DD6C; Tue, 10 Oct 2023 01:20:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 08C6C40E01AE; Tue, 10 Oct 2023 08:20:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Rlcgad57B5RT; Tue, 10 Oct 2023 08:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1696925995; bh=E9CMcde7JhHmBwITrfwM1TdYK1kSavxuW5gL57dtmNY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YO31Bh3hiUYXieWDsQmicGvc7EezBWsDoF2wNwa9LwQ4AmMkUhkQrwJUPVkV0SM76 z/ij/VKF3VaJB8Klvx23jyXwNE0zPSR/+DT5Cz40pg9Dlx2bUKN5OeLJKMHQDGY87g s9LAhd7E8RXdxpSVYTrPiASh73s8nCG37mzj26UUmFhQzJZGtrc++9aEzzYEjbIkVw 9DnrbBwK8T7e0SaTmsWAo1NYc2mrKN5PIkAPC061aFKeaiP45BwOqLxBi7VTaGActF UIruJsMjeckwsc9wkhymlrfSLh3eVaTNczfEfpjwJRfzNzHqz1dEVHlW6EJnMmVQRo /lGlVWFVGM+17KFA1GHHGwtfgo9WZib0Hs/oZ0BR2icCvQbrVAE6PhEoOdguPUvhsR O5nl5Xv78BtpZ0dMA16XVTNeaAqTt+jZJUhG2voVsVSIF3j/ddxsONZoFy4XQOBi4a aiSjuTkok718T6KM9HvwMEh+plK+EO8vfjCT30dAT90VdBpm5+8TTDr4ibalSdZoWr euUxcQKeYhAepXGhTGg1Y2mlb7wMTCNFS3m11Gb1jjGYsRbrPdJun0QW/xfR/s0Imn fXXgFUlAEGLPAVk4rISIrH/iFlbETdE9qqtv0FxxEKTnUzW6aSYuHcWakQHZRC8HxX c+nmBefGdzh9bO1QiGbDnk0U= Received: from zn.tnic (pd953036a.dip0.t-ipconnect.de [217.83.3.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 8C73140E0187; Tue, 10 Oct 2023 08:19:39 +0000 (UTC) Date: Tue, 10 Oct 2023 10:19:38 +0200 From: Borislav Petkov To: "Kirill A. Shutemov" Cc: Thomas Gleixner , Ingo Molnar , Dave Hansen , Peter Zijlstra , 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: [PATCH] x86/alternatives: Disable KASAN on text_poke_early() in apply_alternatives() Message-ID: <20231010081938.GBZSUJGlSvEkFIDnES@fat_crate.local> References: <20231010053716.2481-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231010053716.2481-1-kirill.shutemov@linux.intel.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:21:10 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 08:37:16AM +0300, Kirill A. Shutemov wrote: > On machines with 5-level paging, cpu_feature_enabled(X86_FEATURE_LA57) > got patched. It includes KASAN code, where KASAN_SHADOW_START depends on > __VIRTUAL_MASK_SHIFT, which is defined with the cpu_feature_enabled(). So use boot_cpu_has(X86_FEATURE_LA57). > It seems that KASAN gets confused when apply_alternatives() patches the It seems? > KASAN_SHADOW_START users. A test patch that makes KASAN_SHADOW_START > static, by replacing __VIRTUAL_MASK_SHIFT with 56, fixes the issue. > > During text_poke_early() in apply_alternatives(), KASAN should be > disabled. KASAN is already disabled in non-_early() text_poke(). > > It is unclear why the issue was not reported earlier. Bisecting does not > help. Older kernels trigger the issue less frequently, but it still > occurs. In the absence of any other clear offenders, the initial dynamic > 5-level paging support is to blame. This whole thing sounds like it is still not really clear what is actually happening... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette