From: Tony Luck <tony.luck@intel.com> To: Borislav Petkov <bp@alien8.de> Cc: "Tony Luck" <tony.luck@intel.com>, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Andy Lutomirski" <luto@kernel.org>, "Aili Yao" <yaoaili@kingsoft.com>, "HORIGUCHI NAOYA( 堀口 直也)" <naoya.horiguchi@nec.com> Subject: [PATCH 1/4] x86/mce: Fix copyin code to return -EFAULT on machine check. Date: Thu, 25 Mar 2021 17:02:32 -0700 [thread overview] Message-ID: <20210326000235.370514-2-tony.luck@intel.com> (raw) In-Reply-To: <20210326000235.370514-1-tony.luck@intel.com> When copy from user fails due to a machine check on poison reading user data it should return an error code. --- Separate patch just now, but likely needs to be combined with patches to iteration code for bisection safety. --- arch/x86/lib/copy_user_64.S | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S index 77b9b2a3b5c8..2987118c541a 100644 --- a/arch/x86/lib/copy_user_64.S +++ b/arch/x86/lib/copy_user_64.S @@ -14,6 +14,7 @@ #include <asm/alternative-asm.h> #include <asm/asm.h> #include <asm/smap.h> +#include <asm/errno.h> #include <asm/export.h> #include <asm/trapnr.h> @@ -237,18 +238,21 @@ SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail) cmp $X86_TRAP_MC,%eax /* check if X86_TRAP_MC */ je 3f 1: rep movsb -2: mov %ecx,%eax + mov %ecx,%eax + ASM_CLAC + ret + +2: + cmp $X86_TRAP_MC,%eax + je 3f + mov %ecx,%eax ASM_CLAC ret /* - * Return zero to pretend that this copy succeeded. This - * is counter-intuitive, but needed to prevent the code - * in lib/iov_iter.c from retrying and running back into - * the poison cache line again. The machine check handler - * will ensure that a SIGBUS is sent to the task. + * Return -EFAULT for the machine check cases */ -3: xorl %eax,%eax +3: movl $-EFAULT,%eax ASM_CLAC ret -- 2.29.2
next prev parent reply other threads:[~2021-03-26 0:02 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-26 0:02 [RFC 0/4] Fix machine check recovery for copy_from_user Tony Luck 2021-03-26 0:02 ` Tony Luck [this message] 2021-04-06 19:24 ` [PATCH 1/4] x86/mce: Fix copyin code to return -EFAULT on machine check Borislav Petkov 2021-03-26 0:02 ` [PATCH 2/4] mce/iter: Check for copyin failure & return error up stack Tony Luck 2021-03-26 0:02 ` [PATCH 3/4] mce/copyin: fix to not SIGBUS when copying from user hits poison Tony Luck 2021-04-07 21:18 ` Borislav Petkov 2021-04-07 21:43 ` Luck, Tony 2021-04-08 8:49 ` Borislav Petkov 2021-04-08 17:08 ` Luck, Tony 2021-04-13 10:07 ` Borislav Petkov 2021-04-13 16:13 ` Luck, Tony 2021-04-14 13:05 ` Borislav Petkov 2021-03-26 0:02 ` [PATCH 4/4] x86/mce: Avoid infinite loop for copy from user recovery Tony Luck 2021-04-08 13:36 ` Borislav Petkov 2021-04-08 16:06 ` Luck, Tony 2021-04-08 2:13 ` [RFC 0/4] Fix machine check recovery for copy_from_user Aili Yao 2021-04-08 14:39 ` Luck, Tony 2021-04-09 6:49 ` Aili Yao
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210326000235.370514-2-tony.luck@intel.com \ --to=tony.luck@intel.com \ --cc=bp@alien8.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=luto@kernel.org \ --cc=naoya.horiguchi@nec.com \ --cc=x86@kernel.org \ --cc=yaoaili@kingsoft.com \ --subject='Re: [PATCH 1/4] x86/mce: Fix copyin code to return -EFAULT on machine check.' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).