Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2684068pxb; Thu, 11 Feb 2021 20:57:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZOsm7N4vSv26Qs1/uvynoUU3qBnla/l9RqNYQbfres8MOQsAIeCFCKnccvB8jz4tvzYc8 X-Received: by 2002:aa7:c0cd:: with SMTP id j13mr1517876edp.156.1613105861643; Thu, 11 Feb 2021 20:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613105861; cv=none; d=google.com; s=arc-20160816; b=Z8q144AOUBjv0zDdUQeFy6olqSokyxWP5fCCuQQYba11l0H+bzzYqB0SfQ4eEOCzCS Ht8CVQi4/dsRVLTDnlRXN9jItmUtqdrj6qIrfJHVtwT6KFo0HelTsKs66FZ7QtICQJHp ko4xfHTdZa5Vh7YN0Nnoc4xot6Ue7w/Pn5iC+suTxDsPLhbgD9OlAtSJ1seAhEL4VE4b qOSyhLWwYnFu+HCBbUT/4LVVTP9aaZd498QJLCRPrOFAhr/mHh7mYZekeTUu3R362G5T fRC5PTgQjGjwvt46PswKNDeXU5W+SPPBaJgygX9Y7jcVwfO4TlrwrHpo9RRRfdTKtGXo BnkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tZ2GY7Fp11KsaL/DGIWPHexvS65zfBCwSPbhFnIuVjI=; b=tmsTm8SQC9ZDZRePKv7sPDlLOfkbkGC3wCvJC+D6oKyF0ky8JGPr66jVjjS9G3nAim IFQncttVvA58ryAqDcZpQHQRY19/G3NmsT9y9kY2oy5jk2/7mb9mTLz26Y9gN3Sv0w9C SXiESlYngAhCbv749wAEGAvarOjPCdVgaRJqz2WQszO1jv8y8BTlsrjQc4MLINLgw7SM 5RluGX4SY9CvKvHjnjnQMkGfvjfDF0RT0tmDkm8BEVzPe+ra7p4Ri1enRln+YQNscY4R ihfAI6D+xYjFzJs3kGaqQt7FjvS8YxYeOQ3eOjr1cnX4xqGahf3V7S70VrfHi6+JjzGv bX/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fufx1fqe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt13si5506333ejb.41.2021.02.11.20.57.18; Thu, 11 Feb 2021 20:57:41 -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=@kernel.org header.s=k20201202 header.b=fufx1fqe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbhBLEyb (ORCPT + 99 others); Thu, 11 Feb 2021 23:54:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:38920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbhBLEy3 (ORCPT ); Thu, 11 Feb 2021 23:54:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A360C64E6B; Fri, 12 Feb 2021 04:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613105628; bh=w+W+4jcsNvzGlG2xqLkXfZcesXxw+6R5aF7yQyuCYlQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fufx1fqeM3hxebhjwZhWERVSes40YektvvD4MNwXAAaHX7C385bePfCf/ZYuf+fr4 VjXQzDk1iYeuGWEzuh3XOVDeU0GMdvQMwGiE04pdTP8Ey2qvGFKniDXYZsVisDqE+b Gaw/ot58sSuu2limnbtJ8rm9aQ8gKKHtIzk9mSXVxeZo6gg2BJtx0XRHkUf0O3+H9u 7V9PcHn1ODGg961t8rplR9yfXMxcWhKGvO37JStJYmu3u2f4ZXKG6FZFo5din2ZvxR 2xem+jJDggvi8Wb7uFb8DW3YgGJXnDeBHZbITNgET4eugYTrSEGHkWfZwJd3+9rJJZ t/4ZUlL0taafQ== Date: Thu, 11 Feb 2021 20:53:47 -0800 From: "Darrick J. Wong" To: Nicolas Boichat Cc: Alexander Viro , Ian Lance Taylor , Luis Lozano , Greg KH , Dave Chinner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/6] vfs: Disallow copy_file_range on generated file systems Message-ID: <20210212045347.GM7190@magnolia> References: <20210212044405.4120619-1-drinkcat@chromium.org> <20210212124354.6.Idc9c3110d708aa0df9d8fe5a6246524dc8469dae@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210212124354.6.Idc9c3110d708aa0df9d8fe5a6246524dc8469dae@changeid> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 12:44:05PM +0800, Nicolas Boichat wrote: > copy_file_range (which calls generic_copy_file_checks) uses the > inode file size to adjust the copy count parameter. This breaks > with special filesystems like procfs/sysfs/debugfs/tracefs, where > the file size appears to be zero, but content is actually returned > when a read operation is performed. Other issues would also > happen on partial writes, as the function would attempt to seek > in the input file. > > Use the newly introduced FS_GENERATED_CONTENT filesystem flag > to return -EOPNOTSUPP: applications can then retry with a more > usual read/write based file copy (the fallback code is usually > already present to handle older kernels). > > Signed-off-by: Nicolas Boichat > --- > > fs/read_write.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/read_write.c b/fs/read_write.c > index 0029ff2b0ca8..80322e89fb0a 100644 > --- a/fs/read_write.c > +++ b/fs/read_write.c > @@ -1485,6 +1485,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, > if (flags != 0) > return -EINVAL; > > + if (file_inode(file_in)->i_sb->s_type->fs_flags & FS_GENERATED_CONTENT) > + return -EOPNOTSUPP; Why not declare a dummy copy_file_range_nop function that returns EOPNOTSUPP and point all of these filesystems at it? (Or, I guess in these days where function pointers are the enemy, create a #define that is a cast of 0x1, and fix do_copy_file_range to return EOPNOTSUPP if it sees that?) --D > + > ret = generic_copy_file_checks(file_in, pos_in, file_out, pos_out, &len, > flags); > if (unlikely(ret)) > -- > 2.30.0.478.g8a0d178c01-goog >