Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp778057iog; Mon, 13 Jun 2022 12:45:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqemk1u19V7hli8F3Pej+ufQKSPSz4wwXbe3UGxH71xck4sO1jlm9muWtA0FRancuMYupT X-Received: by 2002:a63:f455:0:b0:3fc:e1c1:bf10 with SMTP id p21-20020a63f455000000b003fce1c1bf10mr1039989pgk.467.1655149543337; Mon, 13 Jun 2022 12:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655149543; cv=none; d=google.com; s=arc-20160816; b=RQH4ojU4Qw1m9iGxaIk0w1wWJdmHuCzmfGfvzGy3PTCwu9VTkPdsybnqE6+F/7/Ksq egsV7Xs5krNbpaRalS10bMyfExWBQa8Dj9SfxvanT1fVDCVPGhGF6F2KGgKKRY5+T5Y8 /VlTYxZhCR6v9Cj/LYzCXgc7MCrpPNjCAhQ6sblHlQdKb5SHizOoCXcBv3evVSbmgYjZ YDvPfHext4qoOMV93YzUMf8urXVHGl8FJ2PE5uyCs5xfs6wpX8FB681x/Ung5UIBflw0 wD7DDy3bAvLpvRcmYNwbDOTRFjyT3kjP9VL9e3iA6ffFMU+Djdl8hm8c1ZM8Ci14ppiF qGZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0yE1F+T2LeAVJ2bFwOtJHGbp283h9GhemqSHAeGwktA=; b=eNXiLH8qBmZnEkMEHXyOOsTQTJ9QsB6ok8jSqOKgTSbSxUGtkjHWY/1Jy+DDq0dSUI Mwr4Xe3Pz4fni9ZWADV5DejNsw6OdmQ11uqHPBTuQEXZMDfpvVxhdcPjS0zEmDGvNqLn 2EA1Jjv1YeDVfxh9WyiMVaQd5htSlwhpaMcPzUdVZgXk4aEO4vUwWSdjzGVfCK7ZcldS jp7Ucajwv3m3rraII7OOfqItmSjhLLyhGgvXD3u8+IJBAEob7PQ2tv0Bm2gZL0DED2P1 vF9qrJt9Splrmh86kB6HMUnY/FaYOxoDwXSdC9yrhJgo1LMYa/pU9yIn4KZPFWIzWx8p JufA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=cV5JPzOc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a655a03000000b003f9f28dd8e9si11298776pgs.794.2022.06.13.12.45.30; Mon, 13 Jun 2022 12:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=cV5JPzOc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349735AbiFMT3w (ORCPT + 99 others); Mon, 13 Jun 2022 15:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351737AbiFMT3k (ORCPT ); Mon, 13 Jun 2022 15:29:40 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5D245DD1D for ; Mon, 13 Jun 2022 10:54:54 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id c2so8243548edf.5 for ; Mon, 13 Jun 2022 10:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0yE1F+T2LeAVJ2bFwOtJHGbp283h9GhemqSHAeGwktA=; b=cV5JPzOcrWUkY/YCBj01CplxNVk0Ypz2tEFigoKe7aUyACwfxpLidnfRJxQUvCHXB8 hXeDqzdFDhPl5UTeyCWepHZO/sI6ZgbBgwwQXwmZisuOyhVixvoN3C2E6lXFMJOFc09R /Hv3Nw2iClVxh/V9udd7r9WBzL/nRXXjTHk6I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0yE1F+T2LeAVJ2bFwOtJHGbp283h9GhemqSHAeGwktA=; b=vQqDQU534fPb4TqkwoJZpY5ZMvwr01idJnm9JHi3rdUdJcmHq9KHOzQJeJTCbqXM7w Orx7kQ4PvZMAnIq/jYCoetgjobFqRImOvfy0xyisXxb8X21BTEhVXNHb0JZmoGYuXuli NPRwV9mYJo5Eh0KXAfx4/kn/BV/qF78DetjqQmcnpniKqkB2QGtD1viuDgWycFrbhM5J c2RD3wiIvFRtlV2djcQvzbNzDFUfQPw9oIE/nOyKkNKqMcnKeNvE0Jx8GwH2P+oSXMOJ dbmtk8ybiyrU5RjW8wFLdLFA+rY7w5NWa7TshkLCIhfFFGFlKxkt70dFV6YRV3Egoihq 9gJg== X-Gm-Message-State: AJIora+09gV78OzAJP4fqkOBjwe7GvsuydC/RkzE8a8mSWh6AAQSyjSX Voqt43aCwzuOb3Vtptr2Ldb3AhtDrIVYL1lX X-Received: by 2002:a05:6402:e81:b0:432:7f12:1878 with SMTP id h1-20020a0564020e8100b004327f121878mr1004817eda.179.1655142893265; Mon, 13 Jun 2022 10:54:53 -0700 (PDT) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com. [209.85.128.41]) by smtp.gmail.com with ESMTPSA id d9-20020a1709063ec900b006feb6dee4absm4102475ejj.137.2022.06.13.10.54.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jun 2022 10:54:52 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id e5so3404749wma.0 for ; Mon, 13 Jun 2022 10:54:52 -0700 (PDT) X-Received: by 2002:a1c:5418:0:b0:39c:3552:c85e with SMTP id i24-20020a1c5418000000b0039c3552c85emr16162741wmb.68.1655142892217; Mon, 13 Jun 2022 10:54:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Mon, 13 Jun 2022 10:54:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC][PATCH] fix short copy handling in copy_mc_pipe_to_iter() To: Al Viro Cc: Dan Williams , Linux Kernel Mailing List , linux-fsdevel , nvdimm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 12, 2022 at 5:10 PM Al Viro wrote: > > Unlike other copying operations on ITER_PIPE, copy_mc_to_iter() can > result in a short copy. In that case we need to trim the unused > buffers, as well as the length of partially filled one - it's not > enough to set ->head, ->iov_offset and ->count to reflect how > much had we copied. Not hard to fix, fortunately... > > I'd put a helper (pipe_discard_from(pipe, head)) into pipe_fs_i.h, > rather than iov_iter.c - Actually, since this "copy_mc_xyz()" stuff is going to be entirely impossible to debug and replicate for any normal situation, I would suggest we take the approach that we (long ago) used to take with copy_from_user(): zero out the destination buffer, so that developers that can't test the faulting behavior don't have to worry about it. And then the existing code is fine: it will break out of the loop, but it won't do the odd revert games and the "randomnoise.len -= rem" thing that I can't wrap my head around. Hmm? Linus