public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Bogus buffer length check in linux-2.6.11  read()
@ 2005-03-15 17:59 linux-os
  2005-03-16  2:56 ` Tom Felker
  0 siblings, 1 reply; 10+ messages in thread
From: linux-os @ 2005-03-15 17:59 UTC (permalink / raw)
  To: Linux kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 719 bytes --]


The attached file shows that the kernel thinks it's doing
something helpful by checking the length of the input
buffer for a read(). It will return "Bad Address" until
the length is 1632 bytes.  Apparently the kernel thinks
1632 is a good length!

Did anybody consider the overhead necessary to do this
and the fact that the kernel has no way of knowing if
the pointer to the buffer is valid until it actually
does the write. What was wrong with copy_to_user()?
Why is there the additional bogus check?

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

[-- Attachment #2: Type: TEXT/PLAIN, Size: 426 bytes --]


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
     char buf[0x100];
     size_t i;
     int val;
     for(i=0x1000; i > 0; i--)
     {
         if((val = read(STDIN_FILENO, buf, i)) == -1)
             perror("read");
         else
         {
             printf("Apparently the kernel thinks %u is a good length!\n", i);
             break;
         }
     }
    return 0;
}

^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <3IoOm-5M2-49@gated-at.bofh.it>]

end of thread, other threads:[~2005-03-16 14:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-15 17:59 Bogus buffer length check in linux-2.6.11 read() linux-os
2005-03-16  2:56 ` Tom Felker
2005-03-16 12:29   ` linux-os
2005-03-16 13:30     ` Ian Campbell
2005-03-16 14:11       ` linux-os
2005-03-16 14:42         ` Eric Dumazet
2005-03-16 14:51           ` linux-os
     [not found] <3IoOm-5M2-49@gated-at.bofh.it>
2005-03-15 23:59 ` Robert Hancock
2005-03-16 12:23   ` linux-os
     [not found] ` <3IwVv-4kD-17@gated-at.bofh.it>
     [not found]   ` <3IFYO-3eg-37@gated-at.bofh.it>
     [not found]     ` <3IGUS-46t-27@gated-at.bofh.it>
     [not found]       ` <3IHxD-4Gb-5@gated-at.bofh.it>
2005-03-16 14:37         ` Robert Hancock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox