Re: [PATCH] mm/nommu.c: Fix improperly call of security API in mmap

From: Eric Paris
Date: Fri Oct 16 2009 - 11:10:06 EST


On Wed, Oct 14, 2009 at 10:08 AM, David Howells <dhowells@xxxxxxxxxx> wrote:
> <graff.yang@xxxxxxxxx> wrote:
>
>> The original code calling security_file_mmap() use user's hint address
>> as it's 5th argument(addr). This is improper, as the hint address may be
>> NULL.
>> In this case, the security_file_mmap() may incorrectly return -EPERM.
>>
>> This patch moved the calling of security_file_mmap() out of
>> validate_mmap_request() to do_mmap_pgoff(), and call this
>> security API with the address that attempting to mmap.
>
> I think this is the wrong approach.  Firstly, the hint is cleared in NOMMU
> mode, and secondly, I think that the check against the minimum LSM address is
> pointless in NOMMU mode too.

I really don't like seeing such irrelevant (that's not the right word,
but I can't think what is) ifdefs creeping down into the security
layer as LSM authors are likely to mess them up in the future. I'd
probably rather see the addr_only argument changed into a flags field.
One for addr_only and one flag for not_addr. The nommu case could
just set the not_addr flag and it's obvious how the LSMs (or
capabilities if !CONFIG_SECURITY) should handle it, also works if some
other future need arises...

-Eric
--
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/