All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dai Ngo <dai.ngo@oracle.com>
To: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH v2] vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF
Date: Mon,  1 Feb 2021 15:49:52 -0500	[thread overview]
Message-ID: <20210201204952.74625-1-dai.ngo@oracle.com> (raw)

Fix by returning -EINVAL instead of 0, per man page of copy_file_range,
when the requested range extends beyond the end of the source file.
Problem was discovered by subtest inter11 of nfstest_ssc.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 75f764b43418..438c00910716 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1445,7 +1445,7 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in,
 	/* Shorten the copy to EOF */
 	size_in = i_size_read(inode_in);
 	if (pos_in >= size_in)
-		count = 0;
+		count = -EINVAL;
 	else
 		count = min(count, size_in - (uint64_t)pos_in);
 
-- 
2.9.5


             reply	other threads:[~2021-02-01 20:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 20:49 Dai Ngo [this message]
2021-02-01 21:14 ` [PATCH v2] vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF Darrick J. Wong
2021-02-01 21:51   ` dai.ngo
2021-02-11 19:54     ` dai.ngo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210201204952.74625-1-dai.ngo@oracle.com \
    --to=dai.ngo@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.