Re: regarding mprotect() implementation in 2.6.26 kernel

From: Jeremy Fitzhardinge
Date: Thu Jul 31 2008 - 11:09:20 EST


Maxin John wrote:
> Dear Christoph Hellwig,
>
> ( I guess you are the right person to ask this question ?)
>
> The POSIX.2 specification of mprotect() says:
>
> errorno should be set as ENOMEM if the addresses in the range [addr,
> (addr + len)] are invalid for the address space of a process, or
> specify one or more pages which are not mapped.
>
> However, in the mprotect implementation (asmlinkage long
> sys_mprotect(unsigned long start, size_t len, unsigned long prot)) in
> linux/mm/mprotect.c file, if we call mprotect() with start as NULL and
> len as 0, mprotect() returns 0 and it is not setting the errono.The
> following code confirms this behaviour.
>

Address 0 is a valid process address. And you've set the length to
zero, so you technically haven't referred to any memory at all, so it
doesn't matter what the address is.

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