From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01451C433DB for ; Tue, 12 Jan 2021 22:05:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 57977223E0 for ; Tue, 12 Jan 2021 22:05:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57977223E0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 49A376B00F9; Tue, 12 Jan 2021 17:05:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 44ADD6B00FA; Tue, 12 Jan 2021 17:05:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35FB06B00FB; Tue, 12 Jan 2021 17:05:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 201596B00F9 for ; Tue, 12 Jan 2021 17:05:00 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D5052181AEF32 for ; Tue, 12 Jan 2021 22:04:58 +0000 (UTC) X-FDA: 77698503876.01.skin04_1e0e72327518 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id AD4DD1004A763 for ; Tue, 12 Jan 2021 22:04:58 +0000 (UTC) X-HE-Tag: skin04_1e0e72327518 X-Filterd-Recvd-Size: 5607 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 22:04:58 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id u4so2586972pjn.4 for ; Tue, 12 Jan 2021 14:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=jp/uGViJd1rFyzqwINzBwHrML5ENBaR5RE09FM8y2rk=; b=o+tEsxdhzGCGsoHV1sIPiVSiNVm3QfIVPZgQqlc+JiLmlwrr+cGXF6VcEO68es1sR5 4sjbYAIz+6YaEKlIsPnQk8QRrpepwBATzotV7rf4CMiOf++gQk+lqxVKH9egpXJwTCL6 gKP+7N8kY+E30jdEsOcYcTtCficEYaP6PMEmbFX7nzUSo2B0UbrYxQDdRX2pO/Yb9o4+ 4N9s2VkD8ozP3B6Zmj0YpZpyxxa5e0UwbJWCZGP3We/ZOQpeUdbFwt/NL5zQ8b5Rf57o cHK6gDSbbSM3KeSMMbf+xAdzFvilac1HfRLY1UPA6ALiHMB9QIw3AgN1kZ5Zn0TdakUo /G5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=jp/uGViJd1rFyzqwINzBwHrML5ENBaR5RE09FM8y2rk=; b=VXzw7QUrjpz9Xm2i7l61DrMZNlKOwngwc1fy7NjwAmJ8MpTyRBMqwfJ1dRhPnjCtCR tsh1XpJ8GbWb+DtUCAYuvhAD00ASDJpJlwNlp9SEcIsrBFgzh7OzrB7+I7P3w2YsSWvQ JFeefkv/znz3U9yVoH+9IWuz2GE3xKyD7Bw+e0cMei+riGF95VsVIeFCsiO2ml2ootPc IfBBnf0fVyWOF6I3weu8DgL2rEhIdKj+MUwfrtamX0gOA3NTGwSklOxlY2/kJWm18R8/ plQrVj3SdB+8yZtNUXpsbOYYDgcxKwHlmt6tDi3PgX/3aRebBQMrWewiCgYUXg0blm4p PVig== X-Gm-Message-State: AOAM533NXk5OAalMVm1uuPuVD/SRoEB9OXWYfPfzzsEUh03p8J0mHpUP LC7JaienSAnXRt2B4SOPKsdQmQ== X-Google-Smtp-Source: ABdhPJy4y2gxKCe1VUOnE5Taoj0S544T+thXTxi76Iku+7ZGDndJn6pDg/pwbWqNbphh8wYmDWx1Cg== X-Received: by 2002:a17:902:d385:b029:da:c6e4:5cab with SMTP id e5-20020a170902d385b02900dac6e45cabmr1450926pld.7.1610489097172; Tue, 12 Jan 2021 14:04:57 -0800 (PST) Received: from ?IPv6:2601:646:c200:1ef2:58cc:4dec:a37:4486? ([2601:646:c200:1ef2:58cc:4dec:a37:4486]) by smtp.gmail.com with ESMTPSA id s1sm79453pfb.103.2021.01.12.14.04.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 14:04:56 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 1/3] x86/mce: Avoid infinite loop for copy from user recovery Date: Tue, 12 Jan 2021 14:04:55 -0800 Message-Id: <38AF04BE-7F39-450F-8C26-879C9934E3D6@amacapital.net> References: <20210112205207.GA18195@agluck-desk2.amr.corp.intel.com> Cc: Andy Lutomirski , Borislav Petkov , X86 ML , Andrew Morton , Peter Zijlstra , Darren Hart , LKML , linux-edac , Linux-MM In-Reply-To: <20210112205207.GA18195@agluck-desk2.amr.corp.intel.com> To: "Luck, Tony" X-Mailer: iPhone Mail (18C66) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > On Jan 12, 2021, at 12:52 PM, Luck, Tony wrote: >=20 > =EF=BB=BFOn Tue, Jan 12, 2021 at 10:57:07AM -0800, Andy Lutomirski wrote: >>> On Tue, Jan 12, 2021 at 10:24 AM Luck, Tony wrote:= >>>=20 >>> On Tue, Jan 12, 2021 at 09:21:21AM -0800, Andy Lutomirski wrote: >>>> Well, we need to do *something* when the first __get_user() trips the >>>> #MC. It would be nice if we could actually fix up the page tables >>>> inside the #MC handler, but, if we're in a pagefault_disable() context >>>> we might have locks held. Heck, we could have the pagetable lock >>>> held, be inside NMI, etc. Skipping the task_work_add() might actually >>>> make sense if we get a second one. >>>>=20 >>>> We won't actually infinite loop in pagefault_disable() context -- if >>>> we would, then we would also infinite loop just from a regular page >>>> fault, too. >>>=20 >>> Fixing the page tables inside the #MC handler to unmap the poison >>> page would indeed be a good solution. But, as you point out, not possibl= e >>> because of locks. >>>=20 >>> Could we take a more drastic approach? We know that this case the kernel= >>> is accessing a user address for the current process. Could the machine >>> check handler just re-write %cr3 to point to a kernel-only page table[1]= . >>> I.e. unmap the entire current user process. >>=20 >> That seems scary, especially if we're in the middle of a context >> switch when this happens. We *could* make it work, but I'm not at all >> convinced it's wise. >=20 > Scary? It's terrifying! >=20 > But we know that the fault happend in a get_user() or copy_from_user() cal= l > (i.e. an RIP with an extable recovery address). Does context switch > access user memory? No, but NMI can. The case that would be very very hard to deal with is if we get an NMI just b= efore IRET/SYSRET and get #MC inside that NMI. What we should probably do is have a percpu list of pending memory failure c= leanups and just accept that we=E2=80=99re going to sometimes get a second M= CE (or third or fourth) before we can get to it. Can we do the cleanup from an interrupt? IPI-to-self might be a credible ap= proach, if so.