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 0C9EBC43461 for ; Thu, 1 Apr 2021 01:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4353610A5 for ; Thu, 1 Apr 2021 01:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbhDABo0 (ORCPT ); Wed, 31 Mar 2021 21:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbhDABoT (ORCPT ); Wed, 31 Mar 2021 21:44:19 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BA2CC061574; Wed, 31 Mar 2021 18:44:19 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lRmNW-001WiT-Sb; Thu, 01 Apr 2021 01:44:11 +0000 Date: Thu, 1 Apr 2021 01:44:10 +0000 From: Al Viro To: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCH 01/18] vfs: introduce new file range exchange ioctl Message-ID: References: <161723932606.3149451.12366114306150243052.stgit@magnolia> <161723933214.3149451.12102627412985512284.stgit@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161723933214.3149451.12102627412985512284.stgit@magnolia> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Wed, Mar 31, 2021 at 06:08:52PM -0700, Darrick J. Wong wrote: > + ret = vfs_xchg_file_range(file1.file, file2, &args); > + if (ret) > + goto fdput; > + > + /* > + * The VFS will set RANGE_FSYNC on its own if the file or inode require > + * synchronous writes. Don't leak this back to userspace. > + */ > + args.flags &= ~FILE_XCHG_RANGE_FSYNC; > + args.flags |= (old_flags & FILE_XCHG_RANGE_FSYNC); > + > + if (copy_to_user(argp, &args, sizeof(args))) > + ret = -EFAULT; Erm... How is userland supposed to figure out whether that EFAULT came before or after the operation? Which of the fields are outputs, anyway? > + /* Don't touch certain kinds of inodes */ > + if (IS_IMMUTABLE(inode1) || IS_IMMUTABLE(inode2)) > + return -EPERM; Append-only should get the same treatment (and IMO if you have O_APPEND on either file, you should get a failure as well).