lkml.org 
[lkml]   [2002]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: mmap() doesn't like certain value...
From
    Hi Denis :)

Thanks for answering :)

> if ((len = PAGE_ALIGN(len)) == 0)
> return addr;

This is the problem.

> if (len > TASK_SIZE)
> return -EINVAL;

And is corrected just by inverting the two quoted code snips :)

If we test for len being greater than TASK_SIZE *before* aligning
it then the function works properly (the alignment will be done
properly in the task address space). No patch needed really ;)

>> I know: this lengths are enormous, nobody uses them, etc... but I
>Looks like you found an obscure corner case. Good!

I'll give a try to the inversion, that should work. I have
written a small stress program for mmap, so in a few hours the patch
will be ready. Must I post it here or send it directly to Marcello?

>> If this is not a bug, but an intended behaviour please excuse me.
>> Moreover, I can provide a patch (I suppose) against the 2.4.18 tree.
>Do it.

Ok :) I'll prepare the patch right now. Unified diff?

>BTW, does anybody know why len==0 is not flagged as error?

Well, I suppose that if you request 0 bytes, any address returned
is valid, since it cannot be accessed (SIGSEGV...). Anyway the man
page for mmap() clearly says that the address returned is NEVER 0, so
we must test for len==0 and invert the other tests.

Thanks a lot for answering, I was supposing that anybody on the
list was ignoring this obvious and easy to correct bug :?

Raúl
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:26    [W:0.040 / U:1.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site