Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp545518pxb; Wed, 11 Nov 2020 09:56:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaCogcljuYfZLa9agGuNulUU8Xuku6l7rKOJLLhWfla9Sl6Mfs0RWBFGrxtcw7KaSvUUzf X-Received: by 2002:aa7:d2d9:: with SMTP id k25mr678206edr.310.1605117384625; Wed, 11 Nov 2020 09:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605117384; cv=none; d=google.com; s=arc-20160816; b=wPQt7VSnOim/72eNtwM00XV19Cm7iewwe/YWC2JsHKH0kxdyI9vqbq6l2vK66KXSl9 VBVRRkuOMb2ZHnME1oJF9+eU00JLumj49hsYbv7VEUpcdrD5XNJ02kr8HMhzKEZvuKfC osWJkBrdAwT/JeeKTTxDx4hdfKS/RmfkwtcAnIynKwMktOutveDd4qbwel5hfbL88kXq HfyLtWF5UhY9qMdGGfcsSULiK47jGDaMhrWQLjPbnFGvXvduhxciZuq4vqyHqmGBmmzE T++yKBNwYq6xfnCpcZeF88U23TZYL5oD5x6dyB+cI6IsR/25LQDnp+x4qbrtaMp6bmVl bV0Q== 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=J5z5ZWxKl1XdvN7r77o5/F7KFBS3l/2PI63c9zLP4QU=; b=VY6gsXFmqQsm4Up7bF+lETiCvuaatu8K9VHSrb6QyUX01CmJJrdGAbPhEUsU2wQCJB YcJwQcifwRUHOpKL4Zzv6fsMZzDdi7DsIbSpCMonQZLyRljW6Xszo+XhjlUQf8j7TaUq P3fqXCFksDFLq2dIDy/UoymxyXIwmq7OYuy2HvPPkGXejT7B7dB53atbF7Diw8jB2bVy C6CsBViz+4d0axNl80LXfiefS0CetCrDTxLLcmeCIH0957UnhEq0rSo8JeavewWzfUAi KliFHh24d0NAav6vQl66QnWQtWsFsNqKP/PDXCm7Yo+PmVo/hrBrWmuEC6p8wYxDqhut mwUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=IJDhODGP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si2001607edp.176.2020.11.11.09.56.01; Wed, 11 Nov 2020 09:56:24 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=IJDhODGP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726412AbgKKRyd (ORCPT + 99 others); Wed, 11 Nov 2020 12:54:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgKKRyd (ORCPT ); Wed, 11 Nov 2020 12:54:33 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D75C0613D4 for ; Wed, 11 Nov 2020 09:54:32 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id e27so4353601lfn.7 for ; Wed, 11 Nov 2020 09:54:32 -0800 (PST) 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=J5z5ZWxKl1XdvN7r77o5/F7KFBS3l/2PI63c9zLP4QU=; b=IJDhODGPEFIKEwMbT+gjJFRHugQW5o0Hlvzl8+o+nf98y8sQ3VdTfAfYeL/5ndK9KW aG8LwYMlatfX1lNMM9AQFeL9Wf4skmcYCGuv7sBm2S/ZhFPbKHTg5BbMp32OoiPTuRIr opV9yB8PTauJ3VpOi/LI/4Fcpb1qDDS0tA4Xc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J5z5ZWxKl1XdvN7r77o5/F7KFBS3l/2PI63c9zLP4QU=; b=QjxCrpeQMpvLDGo749rmae/aTfiwvEhHW5FhD52/PS6/G4wfKh2TBbzLM/EKk08sUl jMpEK4e3uPkQMpyEcuV+coqEUpWghrNqjl1WT77+xZzyCE9af+zaQZD2f/OBsJ/Q+ih/ RQYU7BwPIyOt9X2sqkXxGD0fwQC7Aojem7s213HpOlWsx/oIaK+ZP/ecNO7zqIazbeZa xtOLe9OEHkaVi9DSj4+S9qX2OgA7WAap0itl0gg3Cs4a9VNF9zh8DtR8gHpxBqLJ/2Xw uXhmWqr3eSaismLOwp5GY+tVEWeIfLoYDMHQL+ucT/owc57g1xwXq9tWYTJ//IMw0JDU XLAQ== X-Gm-Message-State: AOAM531MWkdQYgiJQ2U+5YryMeaS3J0iT1jOfM62t0GKJQL6G8iyFVZr EdMh+DPzYnFH1gBvbsOwGUALhSrT8oGdnQ== X-Received: by 2002:a05:6512:20cd:: with SMTP id u13mr3008299lfr.373.1605117270808; Wed, 11 Nov 2020 09:54:30 -0800 (PST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id w12sm296472ljo.67.2020.11.11.09.54.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Nov 2020 09:54:29 -0800 (PST) Received: by mail-lj1-f180.google.com with SMTP id x9so3043975ljc.7 for ; Wed, 11 Nov 2020 09:54:29 -0800 (PST) X-Received: by 2002:a2e:a375:: with SMTP id i21mr8669216ljn.421.1605117268642; Wed, 11 Nov 2020 09:54:28 -0800 (PST) MIME-Version: 1.0 References: <20201104082738.1054792-1-hch@lst.de> <20201104082738.1054792-2-hch@lst.de> <20201110213253.GV3576660@ZenIV.linux.org.uk> <20201110213511.GW3576660@ZenIV.linux.org.uk> <20201110232028.GX3576660@ZenIV.linux.org.uk> In-Reply-To: <20201110232028.GX3576660@ZenIV.linux.org.uk> From: Linus Torvalds Date: Wed, 11 Nov 2020 09:54:12 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/6] seq_file: add seq_read_iter To: Al Viro Cc: Christoph Hellwig , Greg KH , Alexey Dobriyan , linux-fsdevel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 3:20 PM Al Viro wrote: > > Any objections to the following? Well, I don't _object_, but I find it ugly. And I think both the old and the "fixed" code is wrong when an EFAULT happens in the middle. Yes, we can just return EFAULT. But for read() and write() we really try to do the proper partial returns in other places, why not here? IOW, why isn't the proper fix just something like this: diff --git a/fs/seq_file.c b/fs/seq_file.c index 3b20e21604e7..ecc6909b71f5 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -209,7 +209,8 @@ ssize_t seq_read_iter(struct kiocb *iocb, struct iov_iter *iter) /* if not empty - flush it first */ if (m->count) { n = min(m->count, size); - if (copy_to_iter(m->buf + m->from, n, iter) != n) + n = copy_to_iter(m->buf + m->from, n, iter); + if (!n) goto Efault; m->count -= n; m->from += n; which should get the "efault in the middle" case roughly right (ie the usual "exact byte alignment and page crosser" caveats apply). Linus