Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp270732rdh; Wed, 7 Feb 2024 04:31:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0oMGzM5vyPsGRJ4ZpWr9udpY5UUk0tu9KBkOw6uAcKsXUUbUrwgSJ9AKi2Ri0pA8brVmX X-Received: by 2002:a17:90a:34cc:b0:296:c788:b280 with SMTP id m12-20020a17090a34cc00b00296c788b280mr3965182pjf.18.1707309086854; Wed, 07 Feb 2024 04:31:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707309086; cv=pass; d=google.com; s=arc-20160816; b=mlG2IUMTZFuEDHb+elm0EQEHxsnhe3dGEaqGMI226+g9tkb0yXM9f/x641vGY8v58L V9GqLzf9HZJw1O/4yHjhu2MI8xR/JaRgOJn6QYSTWXRLLmQHsa54XTIscJlY6D8wGnW1 HwadiVYnZhddO/dEOXmTaHbr7KtpqwyO2Z9opJX8Vdj+LTQLZqBYV6omUj2JyughfsuR QCoTw91IftboW6zcLKpHa4sLPR12GG9kdXFCXfh9XiNNSn4Y6bKel8Mu/oHF+yeeHa9P 2Dv/JNDEII+DOrr473lhnB/ICjL04eHI1mfOPdqEXJ6NcdSXqCdZhswyIIcy5y16GKhw fRoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=neMQamQmFqij5v0x/QfM0vgH5KoHFOe0tPCa7WZMvKc=; fh=EyLmaBVn2h+t1FC5H8dUnvSOKO8sNe8am5s/JpyKCDI=; b=A83/6cXxEcTZUuMFbdZxPV5JBNzUbDgZSfdDz7MHX0w9YD1fo7d3rj0/2EkRFEKUAo SWMrGT4WvtZC4goWxNzN7wmhFDLxYmN+w+bGmPOvjjQOORF6KpOzrnRg8daxu79Js8pR xwjWEAsbmA8t8meD6wpze6pTQ+nKfkAASVerdsuQwFoq19XQi94/i7R4r82SGO+SX6cj 0wcZ7b0yrdZ7Py+KOjv4Y+Vl9NKX7S7zH7gtQmzdrzGoad2aUSCi46mpDsG/dnlirgW7 2EJQCsmQO+1zmql4xlcN2S+v0lQ9KtLCG5EfsucWAulAf5qJEjvVhzx9IwRh4/M5jWey SHfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b="Dc/tUaMI"; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-56485-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de X-Forwarded-Encrypted: i=2; AJvYcCVhbmDjAxNgz5196Al4PKkCSHsJV1h8bmRK8feokhn4m1acUT6vOWxl82NzIR8nqqQjzCFL7B0H5UN5u2eQ0kxoMfqNDswbX9cYxefJ0g== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t20-20020a17090ad51400b002962ac425b9si1431969pju.94.2024.02.07.04.31.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:31:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56485-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b="Dc/tUaMI"; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-56485-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.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 A56FB28AD7E for ; Wed, 7 Feb 2024 12:30:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BF985A7B7; Wed, 7 Feb 2024 12:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="Dc/tUaMI" Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 CB2EF31755; Wed, 7 Feb 2024 12:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707309018; cv=none; b=FguwPBmtXhFspsgHmDrzuQqihWP19KHrzMLQDyeTePkdLEXKsFo0jzfGSfEIMX2egmt3lS6nqyf3pZmecC/9V+FDr7GXwO0JbouLFpd0PaKmaIywa311q3+u4rDYqffFoQq3Ta5TKVoCpqL/oJ93Lq2MGx6eJSFexj7EKL2Gy7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707309018; c=relaxed/simple; bh=l/I1R6TO971Rm9gzs/Zx8mjrl1tpZ9fmPkTQ0MQ2jl0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rOEylE+pf85SCkzElXuAhYKowZoDTut2+Lqbgs34DivHhDoEnMk4vmcCSq7+i5vbGDWPiDxpIXX04BQ/y2bWgBWLSOFD9qsXpqu27XTL9smJp24AjWF9e0J/r0QDm1eEdkvDdRtEwXfRoniEXykoW1DgUNQSNz/B47TtCsbl0Tc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=Dc/tUaMI; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 4F5FF40E01F7; Wed, 7 Feb 2024 12:30:06 +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 gZmVZCS8ja_O; Wed, 7 Feb 2024 12:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1707309004; bh=neMQamQmFqij5v0x/QfM0vgH5KoHFOe0tPCa7WZMvKc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dc/tUaMIs8BJJUfjfyuOd0jAsrzUmCNX7vTfH8INBqThEFBdRfp5f5FcU0nCscJxH ciR/3tvkZUGI5BWmwxEc/K+uShPxQ1U8pwyVn5LSGjEivfTjNvv6c7QOMozVhPziGc zR5+UOUkPQemarw5nTASgLR2JuIBf7on3fcZUyFVrBJNffgNHceVAN6pcfnofgcZ1d 3ch7oPx5Qh9qEIHLbTJcKVJoO4ZXXqIKOgjhk0nsiryImy9mUnDJNgFCwmnL47XiBJ kTnlUYyS6++th3sY3V6XMzp2hy7qaloJw1l5ttaD1PdhaFrRfA80a6l0bJwsQXwrKi 7d5VTwmh5bn4GNqA+YZ/mmKPFvVaLxjtzy7rEBcQreSXBRYgbitCE2cGvUnsxz6N/e 1RPD48m+EJWxpGdzphhMrMDme0Zq4drsSweBQpe9+n5LsBISgcN6SYw6/T8gWiWnr9 TM+x5zL43AjvXCDV5T8Ygl2lBvImHEyquGayu91mRWEHu1ZCxdY6k2z+Vnark5yAI5 u/B/iWVCE9BxvNREe+g+TejekTIGYHSMFbGfe8hEqsB7S9cbAO5nSVEnom+MZIpHlF NQ+U9RzjChZNdOiT/2BoQ5ZxCoUxNPaNLCF+nfPOe1xE+TQnlzU5ezMtF9Ujz/+mGC RaSl75FL3SvjkWhxJlkYDvbU= Received: from zn.tnic (pd953021b.dip0.t-ipconnect.de [217.83.2.27]) (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 AB74B40E016D; Wed, 7 Feb 2024 12:29:47 +0000 (UTC) Date: Wed, 7 Feb 2024 13:29:42 +0100 From: Borislav Petkov To: Tong Tiangen Cc: Thomas Gleixner , Ingo Molnar , wangkefeng.wang@huawei.com, Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Tony Luck , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Naoya Horiguchi , linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-mm@kvack.org, Guohanjun Subject: Re: [PATCH -next v5 2/3] x86/mce: set MCE_IN_KERNEL_COPYIN for DEFAULT_MCE_SAFE exception Message-ID: <20240207122942.GRZcN3tqWkV-WE-pak@fat_crate.local> References: <20240204082627.3892816-1-tongtiangen@huawei.com> <20240204082627.3892816-3-tongtiangen@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240204082627.3892816-3-tongtiangen@huawei.com> On Sun, Feb 04, 2024 at 04:26:26PM +0800, Tong Tiangen wrote: > diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c > index bca780fa5e57..b2cce1b6c96d 100644 > --- a/arch/x86/kernel/cpu/mce/severity.c > +++ b/arch/x86/kernel/cpu/mce/severity.c > @@ -292,11 +292,11 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs) > case EX_TYPE_UACCESS: > if (!copy_user) > return IN_KERNEL; > + fallthrough; > + case EX_TYPE_DEFAULT_MCE_SAFE: > m->kflags |= MCE_IN_KERNEL_COPYIN; > fallthrough; I knew something was still bugging me here and this is still wrong. Let's imagine this flow: copy_mc_to_user() - note *src is kernel memory |-> copy_mc_enhanced_fast_string or copy_mc_fragile - it's the same thing |-> -#MC, exception type EX_TYPE_DEFAULT_MCE_SAFE |-> error_context(): case EX_TYPE_DEFAULT_MCE_SAFE: m->kflags |= MCE_IN_KERNEL_COPYIN; MCE_IN_KERNEL_COPYIN does kill_me_never(): pr_err("Kernel accessed poison in user space at %llx\n", p->mce_addr); but that's reading from kernel memory! IOW, I *think* that switch statement should be this: switch (fixup_type) { case EX_TYPE_UACCESS: case EX_TYPE_DEFAULT_MCE_SAFE: if (!copy_user) return IN_KERNEL; m->kflags |= MCE_IN_KERNEL_COPYIN; fallthrough; case EX_TYPE_FAULT_MCE_SAFE: m->kflags |= MCE_IN_KERNEL_RECOV; return IN_KERNEL_RECOV; default: return IN_KERNEL; } Provided I'm not missing a case and provided is_copy_from_user() really detects all cases properly. And then patch 3 is wrong because we only can handle "copy in" - not just any copy. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette