Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1179145pxb; Thu, 28 Jan 2021 09:45:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+mmdSEQPxrGWARo4PwpIsmjQikZkubnQtiHgJHQ/+NhT7WnMQklGheGJrnqP2LLbYslyy X-Received: by 2002:a17:906:3fc1:: with SMTP id k1mr592506ejj.58.1611855958517; Thu, 28 Jan 2021 09:45:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611855958; cv=none; d=google.com; s=arc-20160816; b=ukCmhPQzXESSCHsLKOVQhAadJKPNtUIUIFaHpyemK6/7qDq0SiyLA8Kqu1XFrYSuoM c+s+p4qQMCo5hmk4w7h3jway+P/yiNY3a+BAzIW7UsOddbBtr3mG5wyGnsg+iPFTVgWh rCueSd04RRAO3CCJgMg3wPAdmx4w56G7dhTdw9/Rkjpxky56tXQKQbyTCznDvgSsgWFH 1rbShS1YhxUja85SOCLrYXb9a1s80zSX6uFRrgVdV0aKAbFVfaaQn6gle6UZF5osa9b1 4fg8ycjKRMyc51+uXr/1ve1rRwGDR2+JiBuJwltC/vIkPxExOgtd/ub92pbLRa4naVD5 hCNQ== 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:ironport-sdr :ironport-sdr; bh=T6UlcIXCN688LJhDOLN6Oy9YrYQVoI1lXC9Ax9SBXjk=; b=eb6cPAeXmGiz/kWN2es38U2zCUidrR5yADuOZ9rb8F9Ny/TRkdDNhF20nod3isBCms K4NwWaQrKHgRDWEqVRHOZFxGtbW0HmyiGhKb5ILHGHMnBtNlPiI7kY3RFGcqHVjxRnk8 uYzVPKv9PBtjwC/5kyMwKXSlJ9osFR/eEOrm79wQXPdt4zfofRkofC+npk6ksUqgLl6Y kZxpUSooQYmceLeo5+eGpbze1GhA3BmoyED2BwpmIFRhpsbGxjejqkTr+zYmrRJ2GyiF KEuNE8zdiKKDHt6C1qjiOomlu+CL6K68jHlcc094uu8rIygbiAiNOMpHBrR2slpv17zY u65Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si4187851edn.311.2021.01.28.09.45.34; Thu, 28 Jan 2021 09:45:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232797AbhA1Roz (ORCPT + 99 others); Thu, 28 Jan 2021 12:44:55 -0500 Received: from mga01.intel.com ([192.55.52.88]:16768 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233210AbhA1Roi (ORCPT ); Thu, 28 Jan 2021 12:44:38 -0500 IronPort-SDR: dy4myhAHGRzpyFfYhz38AlXOkO/YQ1lNbC+bzwuJWAw35lEc5MKQ1FIqgHj3eDR7kKexfKqFh6 TFXgi9NihMgg== X-IronPort-AV: E=McAfee;i="6000,8403,9878"; a="199115195" X-IronPort-AV: E=Sophos;i="5.79,383,1602572400"; d="scan'208";a="199115195" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2021 09:43:53 -0800 IronPort-SDR: bHzDr4KVfojn+jzni5nYFplQaM5auMhTIKsKDG6rUoV1f94Wuphi1lCXpWg4TuU5G3j6oO34S7 xN16GtSC8QnA== X-IronPort-AV: E=Sophos;i="5.79,383,1602572400"; d="scan'208";a="363886580" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.146]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2021 09:43:53 -0800 Date: Thu, 28 Jan 2021 09:43:52 -0800 From: "Luck, Tony" To: Aili Yao Cc: x86@kernel.org, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org, yangfeng1@kingsoft.com Subject: Re: [PATCH] x86/fault: Send SIGBUS to user process always for hwpoison page access. Message-ID: <20210128174352.GA33283@agluck-desk2.amr.corp.intel.com> References: <20210128194326.71895e92.yaoaili@kingsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210128194326.71895e92.yaoaili@kingsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 07:43:26PM +0800, Aili Yao wrote: > when one page is already hwpoisoned by AO action, process may not be > killed, the process mapping this page may make a syscall include this > page and result to trigger a VM_FAULT_HWPOISON fault, as it's in kernel > mode it may be fixed by fixup_exception, current code will just return > error code to user process. Shouldn't the AO action that poisoned the page have also unmapped it? > > This is not suffient, we should send a SIGBUS to the process and log the > info to console, as we can't trust the process will handle the error > correctly. I agree with this part ... few apps check for -EFAULT and do the right thing. But I'm not sure how this happens. Can you provide a bit more detail on the steps -Tony P.S. Typo: s/suffient/sufficient/ > > Suggested-by: Feng Yang > Signed-off-by: Aili Yao > --- > arch/x86/mm/fault.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index f1f1b5a0956a..36d1e385512b 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -662,7 +662,16 @@ no_context(struct pt_regs *regs, unsigned long error_code, > * In this case we need to make sure we're not recursively > * faulting through the emulate_vsyscall() logic. > */ > +#ifdef CONFIG_MEMORY_FAILURE > + if (si_code == BUS_MCEERR_AR && signal == SIGBUS) > + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", > + current->comm, current->pid, address); > + > + if ((current->thread.sig_on_uaccess_err && signal) || > + (si_code == BUS_MCEERR_AR && signal == SIGBUS)) { > +#else > if (current->thread.sig_on_uaccess_err && signal) { > +#endif > sanitize_error_code(address, &error_code); > > set_signal_archinfo(address, error_code); > @@ -927,7 +936,14 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, > { > /* Kernel mode? Handle exceptions or die: */ > if (!(error_code & X86_PF_USER)) { > +#ifdef CONFIG_MEMORY_FAILURE > + if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) > + no_context(regs, error_code, address, SIGBUS, BUS_MCEERR_AR); > + else > + no_context(regs, error_code, address, SIGBUS, BUS_ADRERR); > +#else > no_context(regs, error_code, address, SIGBUS, BUS_ADRERR); > +#endif > return; > } > > -- > 2.25.1 >