From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD485C4320A for ; Sat, 24 Jul 2021 20:26:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9516C60E78 for ; Sat, 24 Jul 2021 20:26:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhGXTqD (ORCPT ); Sat, 24 Jul 2021 15:46:03 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:47568 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbhGXTqC (ORCPT ); Sat, 24 Jul 2021 15:46:02 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7OC1-003eaC-FU; Sat, 24 Jul 2021 20:24:17 +0000 Date: Sat, 24 Jul 2021 20:24:17 +0000 From: Al Viro To: Linus Torvalds Cc: Andreas Gruenbacher , Christoph Hellwig , "Darrick J. Wong" , Jan Kara , Matthew Wilcox , cluster-devel , linux-fsdevel , Linux Kernel Mailing List , ocfs2-devel@oss.oracle.com Subject: Re: [PATCH v4 1/8] iov_iter: Introduce iov_iter_fault_in_writeable helper Message-ID: References: <20210724193449.361667-1-agruenba@redhat.com> <20210724193449.361667-2-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 24, 2021 at 12:52:34PM -0700, Linus Torvalds wrote: > ... > > + if (fault_in_user_pages(start, len, true) != len) > > + return -EFAULT; > > Looking at this once more, I think this is likely wrong. > > Why? > > Because any user can/should only care about at least *part* of the > area being writable. > > Imagine that you're doing a large read. If the *first* page is > writable, you should still return the partial read, not -EFAULT. Agreed. > So I think the code needs to return 0 if _any_ fault was successful. s/any/the first/... The same goes for fault-in for read, of course; I've a half-baked conversion to such semantics (-EFAULT vs. 0; precise length is unreliable anyway, especially if you have sub-page failure areas), need to finish and post it...