Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1363065imm; Tue, 3 Jul 2018 09:49:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfRdAhh8sbgubvNUwGvbGR8xbIfibjyNTqwfDU4ERG3SL+ssV3L7rZDQ18zpjYaDEOielZz X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr30090696pfx.246.1530636547518; Tue, 03 Jul 2018 09:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530636547; cv=none; d=google.com; s=arc-20160816; b=ub0DPEhmQcNGIxE04bkvWQ8DT/ex28DAPOEcjZy9d7JvDcuT57Z76dIOV//JSj6IzK cI8z0ZYyD5V/ow8TYHcqYfBba+BvVLic/Hm+sDkyr2H/IWSgbD0QhaNjJCYeyeCAD8qK khOKqMvx4p8bpO12UB11yJxaB+hog0bbL85YVyKXT1hmsNLT92LoBACu91gL4bBVaPGW PY4JrQqVTZdqXpT+/9Wm8WzA5N4hZOh00kDPuJ+IT5TKTM0dDemOIRTx0JkN1yH8N22C o7mUm+tCvtb4Gs+oHYvSpVWPDcTuYWaUwYcr/+CrShO9F7dSARCw5RhSaEEMlZA5VAhX ZSwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=qGy0KS/01VaEADblbjjGXGVFdddgqIkw2NUXex4vohE=; b=foPVuPb9JY2PyKfYquRon1WYrfbClk4FDQBgr+wIt39IGBvVmv7Y4BgX/N18rAMssF 390Q/9jCpmfcqmZy7iydbIJzpO2pVIoF9XogqAMpBg0/wKgHOP04eb/qXONM009UyCms Z9TXU4Dq/yFfweGIBxn+dyzl8dTDV0XQUMK68wLkax0ZrZBeNMbYft/m8bJGmmLBT4MC irElV62PduMfic/ImvLxhGNHHSFRk5xlhBxN6M8NlkX/vo0VLUSnquk4/ujdsumMBhAd 7d7stuWMJqBhXDzmoleVJqKomEAan7G98AwzE7jlC2XFX3KPTI8A+s1nGSq31GuTZ/Sm g6iQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id m18-v6si1340024pgi.688.2018.07.03.09.48.52; Tue, 03 Jul 2018 09:49:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S934199AbeGCQsA (ORCPT + 99 others); Tue, 3 Jul 2018 12:48:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:17109 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933992AbeGCQr5 (ORCPT ); Tue, 3 Jul 2018 12:47:57 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 09:47:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,304,1526367600"; d="scan'208";a="69780405" Received: from theros.lm.intel.com (HELO linux.intel.com) ([10.232.112.164]) by orsmga001.jf.intel.com with ESMTP; 03 Jul 2018 09:47:54 -0700 Date: Tue, 3 Jul 2018 10:47:54 -0600 From: Ross Zwisler To: Dan Williams Cc: mingo@kernel.org, Al Viro , Andrew Morton , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Tony Luck , Ross Zwisler , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling Message-ID: <20180703164754.GB30451@linux.intel.com> Mail-Followup-To: Ross Zwisler , Dan Williams , mingo@kernel.org, Al Viro , Andrew Morton , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Tony Luck , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, x86@kernel.org References: <20180702165803.GB19488@linux.intel.com> <153056565378.3420.295180898468362039.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <153056565378.3420.295180898468362039.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 02, 2018 at 02:16:10PM -0700, Dan Williams wrote: > All copy_to_user() implementations need to be prepared to handle faults > accessing userspace. The __memcpy_mcsafe() implementation handles both > mmu-faults on the user destination and machine-check-exceptions on the > source buffer. However, the memcpy_mcsafe() wrapper may silently > fallback to memcpy() depending on build options and cpu-capabilities. > > Force copy_to_user_mcsafe() to always use __memcpy_mcsafe() when > available, and otherwise disable all of the copy_to_user_mcsafe() > infrastructure when __memcpy_mcsafe() is not available, i.e. > CONFIG_X86_MCE=n. > > This fixes crashes of the form: > run fstests generic/323 at 2018-07-02 12:46:23 > BUG: unable to handle kernel paging request at 00007f0d50001000 > RIP: 0010:__memcpy+0x12/0x20 > [..] > Call Trace: > copyout_mcsafe+0x3a/0x50 > _copy_to_iter_mcsafe+0xa1/0x4a0 > ? dax_alive+0x30/0x50 > dax_iomap_actor+0x1f9/0x280 > ? dax_iomap_rw+0x100/0x100 > iomap_apply+0xba/0x130 > ? dax_iomap_rw+0x100/0x100 > dax_iomap_rw+0x95/0x100 > ? dax_iomap_rw+0x100/0x100 > xfs_file_dax_read+0x7b/0x1d0 [xfs] > xfs_file_read_iter+0xa7/0xc0 [xfs] > aio_read+0x11c/0x1a0 > > Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()") > Cc: Al Viro > Cc: Andrew Morton > Cc: Andy Lutomirski > Cc: Borislav Petkov > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: Tony Luck > Reported-by: Ross Zwisler > Signed-off-by: Dan Williams Tested-by: Ross Zwisler