Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp535363lqs; Tue, 5 Mar 2024 08:53:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVuI/3IE4wze70Zjo9AGsrylFUIZSvox7lJpcJQsQZwvyLSmcvd3FdLlZfFjSXR9EqbarnWBUe4ERXLqdv26pWxPJqI516hAimfUHlNyw== X-Google-Smtp-Source: AGHT+IHVv0/nCEb8kJQtqBHgXbTOowlyx+2v8mp0MWSeK6Hz21iDxa8VFmA0iT+nvO2vTm3ZeTnq X-Received: by 2002:a17:90a:f68e:b0:29b:626a:1c43 with SMTP id cl14-20020a17090af68e00b0029b626a1c43mr3758024pjb.5.1709657593425; Tue, 05 Mar 2024 08:53:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709657593; cv=pass; d=google.com; s=arc-20160816; b=COCDQhmbbbwGvPzXJS6xnDG1dea7QC5AJkRP/w8fHjh84gP+kQ6d3/vReAx0VMyCWa F6dh6FGpQtn1AKt1gMhNBxZF8ywN/Gg3n93p5xkwGcGoCLask2lN+evFaOFozZiY40bs +6uDyhEjuG1V18naR8EHufhoFvThqBQalJ695EUgfAKs+fVzYOS2XzHmkyM4FPDH3iSl ZGurgo34RRHtbADDila3J6tegfG75fyTK3Tp/8YaDLiMCPDn3pLkTFM4mFawzyOkHpO0 HZDyJ1CYRH644NsxHAYTHzOMF5XMcSE+i0Jn4xwf7p229oD2J1uWZcena5xH54wNT9bl 2dhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=hlmQlLMlayfFzLpIbgYp3Xuxdad+NM4BJi9zn3V/LbY=; fh=EyByHj1l7Ow8FgX+wypmxPqUiOTXsIi5D0uG2WjC9Pc=; b=VCjDls73wDHpYwKXH1DYJUoXQn7wczUI+341bWLOO5KvQx2yBuPHmOo+b7N3DW0um5 fRQf5s5URsNCievYU0RTv0dgDk/vKL010v5syMOvsxT5cjg2LNQEWzD+HYJaAYN4F0Cq ncEYFbcBP8BSqR6t+6TlbdoQMDWroyXJ0yFGQsyTRsIQ6oW49ThjLyO5NuBS2cw6vDNL oFmU/OxS/gv5L8QRRCPXyG3bllaC6MVHKiwyvGLDgi6bbhdr0oaZISzM7TgNffvAp+WD 4p5gLdy/4gwW3/UG54Gyn5GAZU+xfOSri5Vow3sANEqaL4B5QUxl17enAOMQKe1Krzud rjEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=goTFMAQt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bxJ4UUkV; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-92712-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d13-20020a63d64d000000b005b7160263f2si10004774pgj.154.2024.03.05.08.53.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 08:53:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92712-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=goTFMAQt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bxJ4UUkV; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-92712-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BD059283936 for ; Tue, 5 Mar 2024 16:51:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D605EDDAD; Tue, 5 Mar 2024 16:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="goTFMAQt"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bxJ4UUkV" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B51EDDB3 for ; Tue, 5 Mar 2024 16:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709657456; cv=none; b=gNkLf1Qs4ei7nsOo8kZk61pTcUDvfXEKGswx6SAAtZPe4M8m1Kc9QzsWD4OE4xOMJSy16bJBRWU3kzAhWERlhs+6To4cRte/FZ/RtcgFJJvQ9v7VXzbwWEGy4SjDXjncGoy+zTEc4HHj99zsY054VtI8yFYytApT79OiVfBZB68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709657456; c=relaxed/simple; bh=/czM1to18GyklSjPalpolZHpMa2KefWb0zNihkLXQPg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=G2BuajU9WHnBXPCqxorY/bskwl+uudj7HBdNVsUyS0U+SIBF5K5PrZbYainzkeOcQToPN8a8hIQ9+hR6XjbMtuQUcJOCIWqKYGKPnKmRTYC/ATBc/nVeGvGtImeX0I+RSXwgA7/JEuKrmm6pLKlmQd8+qkpekSnX53y8fDRSStI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=goTFMAQt; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bxJ4UUkV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709657452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hlmQlLMlayfFzLpIbgYp3Xuxdad+NM4BJi9zn3V/LbY=; b=goTFMAQtUDYG4StVi/S6RvagEcrITPQ3gz2e6fS6/91WMTcQTu20S8raGJDRSLYrCRcqGX bvnu56KDPziqo5mkWTVh1r4GUtN4IM4sHNagP16Z3tiHYGcy5gJ1OeMt2Ac7Y3rjh4SQUS DhDOpYHAojnfB4C1Wmkejgw8Js/q6bUE4typjLyyYIDUGNdM6v//M+mE02v131U78RNETo 1Qzt9Ux9GpTMI/1WVzVVwjhmUI1i2hgc+Sn1ijJihRQ/5/aDNaVQeCvzgobHHCwPsklxHc QZvCCkcyU/7F2fJyia88SqQyqBlUjiH4RDOqpOzlRx67tbJfzjohq37PJUj16w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709657452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hlmQlLMlayfFzLpIbgYp3Xuxdad+NM4BJi9zn3V/LbY=; b=bxJ4UUkVpVI9POFazLErv4cOKxtnZGxAtbPU55ucR5AJSSbW1rShDi0RD9a2k/c99nXIuh X8TNEJtYxCwkPwBQ== To: Dave Hansen , Tetsuo Handa , LKML , the arch/x86 maintainers Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: Re: [PATCH v2] x86: disable non-instrumented version of copy_mc when KMSAN is enabled In-Reply-To: <74d900cf-ab90-49ea-ba55-380d7df59526@intel.com> References: <3b7dbd88-0861-4638-b2d2-911c97a4cadf@I-love.SAKURA.ne.jp> <74d900cf-ab90-49ea-ba55-380d7df59526@intel.com> Date: Tue, 05 Mar 2024 17:50:51 +0100 Message-ID: <87jzmgvd04.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, Mar 05 2024 at 07:21, Dave Hansen wrote: > On 3/1/24 14:52, Tetsuo Handa wrote: >> - if (static_cpu_has(X86_FEATURE_ERMS)) { >> + if (!IS_ENABLED(CONFIG_KMSAN) && static_cpu_has(X86_FEATURE_ERMS)) { >> __uaccess_begin(); >> ret = copy_mc_enhanced_fast_string((__force void *)dst, src, len); >> __uaccess_end(); > > Where does the false positive _come_ from? Can we fix copy_mc_fragile() > and copy_mc_enhanced_fast_string() instead of just not using them? All it takes is a variant of __msan_memcpy() which uses a variant of copy_mc_to_kernel() instead of __memcpy(). It's not rocket science. Aside of that, this: @@ -74,14 +74,14 @@ unsigned long __must_check copy_mc_to_user(void __user *dst, const void *src, un { unsigned long ret; - if (copy_mc_fragile_enabled) { + if (!IS_ENABLED(CONFIG_KMSAN) && copy_mc_fragile_enabled) { __uaccess_begin(); is completely bogus. copy_user_generic() is not at all covered by KMSAN. So why fiddling with it in the first place? Just because it has the same pattern as copy_mc_to_kernel()? > The three enable_copy_mc_fragile() are presumably doing so for a > reason. Very much so. It's for MCE recovery purposes. And yes, the changelog and the non-existing comments should explain why this is "correct" when KMSAN is enabled. Hint: It is NOT. Thanks, tglx