mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <ak@muc.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Andi Kleen <ak@muc.de>, Jan Kasprzak <kas@informatics.muni.cz>,
	linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: sendfile -EOVERFLOW on AMD64
Date: 19 May 2004 14:57:26 +0200	[thread overview]
Date: Wed, 19 May 2004 14:57:26 +0200	[thread overview]
Message-ID: <20040519125726.GB68902@colin2.muc.de> (raw)
In-Reply-To: <20040519125036.GM30909@devserv.devel.redhat.com>

> The userland prototypes are:
> extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *__offset,
>                          size_t __count) __THROW;
> extern ssize_t sendfile64 (int __out_fd, int __in_fd, __off64_t *__offset,
>                            size_t __count) __THROW;
> Thus you really cannot transfer more than 4G-1 bytes in one call on 32-bit
> arches.

True.

> Actually, already any counts >= 2GB-1 might be problematic, but we are
> there on the same boat as with e.g. read(2).  For read, POSIX says:
> "If the value of nbyte is greater than {SSIZE_MAX}, the result is
> implementation-defined."
> so portable programs really shouldn't try to transfer more than that
> in one go but the kernel certainly should try to handle sizes up to
> SIZE_MAX-4096 or something like that.

Hmm, ssize_t is signed. If there are any if (ret < 0) checks in the
kernel it will fail too. So the real limit would be 0x7fffffff

Perhaps that should be enforced like this?


diff -u linux/fs/read_write.c-o linux/fs/read_write.c
--- linux/fs/read_write.c-o	2004-05-18 10:55:54.000000000 +0200
+++ linux/fs/read_write.c	2004-05-19 14:57:06.000000000 +0200
@@ -700,6 +700,9 @@
 	off_t off;
 	ssize_t ret;
 
+	if (sizeof(size_t) == 4 && (int)count < 0)
+		return -EOVERFLOW;
+
 	if (offset) {
 		if (unlikely(get_user(off, offset)))
 			return -EFAULT;
@@ -718,6 +721,9 @@
 	loff_t pos;
 	ssize_t ret;
 
+	if (sizeof(size_t) == 4 && (int)count < 0)
+		return -EOVERFLOW;
+		
 	if (offset) {
 		if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
 			return -EFAULT;

-Andi

  reply	other threads:[~2004-05-19 12:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1XuW9-3G0-23@gated-at.bofh.it>
2004-05-19  9:29 ` Andi Kleen
2004-05-19 10:38   ` Jan Kasprzak
2004-05-19 10:58     ` Jakub Jelinek
2004-05-19 11:01       ` Jan Kasprzak
2004-05-19 11:22         ` Nathan Scott
2004-05-19 11:13       ` Nathan Scott
2004-05-19 12:44       ` Andi Kleen
2004-05-19 12:50         ` Jakub Jelinek
2004-05-19 12:57           ` Andi Kleen [this message]
2004-05-19 19:48       ` Jan Kasprzak
2004-05-19  8:44 Jan Kasprzak

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=20040519125726.GB68902@colin2.muc.de \
    --to=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=jakub@redhat.com \
    --cc=kas@informatics.muni.cz \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®