Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2953555imm; Sun, 1 Jul 2018 09:03:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfXjXqLvFyCQ1Ky5omfgY24DUfwy2CC/QX/38Q1gZbsu9wkdXEtIFQ3blIfdgQkYUJDmEUf X-Received: by 2002:a63:9902:: with SMTP id d2-v6mr10769569pge.343.1530461029524; Sun, 01 Jul 2018 09:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530461029; cv=none; d=google.com; s=arc-20160816; b=uriM/I+dVF1q92ptaQu6l9WyanrhfT022bHpFjJow+H0xCyeNPl5xvLt2Q287Kp2vs Jb0/+arlpEivIClk7H2elQgCImjFsGvdN95DnXmafAQmsEFFvaMfZuahpilpsDecJhWF iytB/GMSZjCugLFyABjYJmJpbHT+5acrixQU/6zMkPa5GXBBH6z/l0sAurUAMZ86kw+R HnEjo/dpbNYa8/sTk3752vRCxQxDgQmPId0SagRVlITHtoRXnIwvieuKgZlyPNfL/W+5 5O7g6ezwkZAog1pt6O1ZpNb3jNfUAohoZHtjNZeQu/dT7ia6rhooF/T6X0exi8KzYAQ9 d9PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject :arc-authentication-results; bh=Nf27e2rtXCsNoC32hCOwhrI2w4E4Vd3R+k9Bvdw2vOw=; b=eJOcgyBOuGhIRfj+pzisrOEHunaxvxMO4NZvZXcBnMwPgKKG4aGgKvWUZ7McW6rn3x WWS2I32sdosSuWFrfemwccdILEQo8+jeFTdt4xaJwacw1xsOwnHHolMdV59SCT+al5i6 DugU5lfVMfqVbHzHyMWH3XU7tr0cPIT9Jxa/ncT+nB1PfhKjUjEjOfFPY05e2CJ3GrRD urSbblL8hd8LV0xO2S23PyHxO3Uvz9ZI4OZDTdOaIs8XRQPDq+bbr8fNQ6/ex8/YQRyH ANjcfT6vkuyRASsGUht0t0qLexkWpHT1Ht2E6cYdyvMZGM7Q/EdHzSRGZMVVF9MWSrd8 e8sg== 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 m11-v6si14436626plt.284.2018.07.01.09.03.23; Sun, 01 Jul 2018 09:03:49 -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 S1752373AbeGAQCV (ORCPT + 99 others); Sun, 1 Jul 2018 12:02:21 -0400 Received: from mga05.intel.com ([192.55.52.43]:29350 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752217AbeGAQCT (ORCPT ); Sun, 1 Jul 2018 12:02:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jul 2018 09:02:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,295,1526367600"; d="scan'208";a="51250016" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga007.fm.intel.com with ESMTP; 01 Jul 2018 09:02:18 -0700 Subject: [PATCH] lib/iov_iter: Fix pipe handling in _copy_to_iter_mcsafe From: Dan Williams To: mingo@kernel.org Cc: 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 Date: Sun, 01 Jul 2018 08:52:20 -0700 Message-ID: <153046008813.2019.6356018879675062644.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By mistake the ITER_PIPE early-exit / warning from copy_from_iter() was cargo-culted in _copy_to_iter_mcsafe() rather than a machine-check-safe version of copy_to_iter_pipe(). Implement copy_pipe_to_iter_mcsafe() being careful to return the indication of short copies due to a CPU exception. Without this regression-fix all splice reads to dax-mode files fail. 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 --- Hi Ingo, I'm submitting this fix back through the tip tree since the regression originated through tip/x86/dax. lib/iov_iter.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 7e43cd54c84c..d4c5de8d6fba 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -596,15 +596,44 @@ static unsigned long memcpy_mcsafe_to_page(struct page *page, size_t offset, return ret; } +static size_t copy_pipe_to_iter_mcsafe(const void *addr, size_t bytes, + struct iov_iter *i) +{ + struct pipe_inode_info *pipe = i->pipe; + size_t n, off, xfer = 0; + int idx; + + if (!sanity(i)) + return 0; + + bytes = n = push_pipe(i, bytes, &idx, &off); + if (unlikely(!n)) + return 0; + for ( ; n; idx = next_idx(idx, pipe), off = 0) { + size_t chunk = min_t(size_t, n, PAGE_SIZE - off); + unsigned long rem; + + rem = memcpy_mcsafe_to_page(pipe->bufs[idx].page, off, addr, + chunk); + i->idx = idx; + i->iov_offset = off + chunk - rem; + xfer += chunk - rem; + if (rem) + break; + n -= chunk; + addr += chunk; + } + i->count -= xfer; + return xfer; +} + size_t _copy_to_iter_mcsafe(const void *addr, size_t bytes, struct iov_iter *i) { const char *from = addr; unsigned long rem, curr_addr, s_addr = (unsigned long) addr; - if (unlikely(i->type & ITER_PIPE)) { - WARN_ON(1); - return 0; - } + if (unlikely(i->type & ITER_PIPE)) + return copy_pipe_to_iter_mcsafe(addr, bytes, i); if (iter_is_iovec(i)) might_fault(); iterate_and_advance(i, bytes, v,