Re: [PATCH 1/2] LSM: Do not apply mmap_min_addr check to PROT_NONE mappings

From: Roland McGrath
Date: Sat Oct 22 2011 - 13:24:55 EST


> So I'm not against this, but I'm wondering what triggers the need for it?
>
> It does make the security checks more complicated, since now
> mprotect() suddenly has to care about mmap_min_addr. So I don't think
> it's a security enhancement ("attempt to ensure robustness").
>
> But if there is some actual use-case that is shown to be helped,
> please document that n the explanations for the changeset.

It's exactly the case that I did mention: an application's own attempt to
ensure robustness by doing a PROT_NONE mmap of the [0,0x10000) region. An
application cannot presume that this region is already precluded from being
used by any non-MAP_FIXED mmap across all systems and configurations, so
it's defensive coding to explicitly block it off with a PROT_NONE mapping.

Since we know mmap_min_addr-type constraints might exist, we start at 0 and
move up a page as long as mmap fails. That works fine to cover e.g. the
[0x1000,0x10000) region when mmap_min_addr is set to 4096, as is common.
However, under SELinux these harmless attempts are diagnosed as MMAP_ZERO
avc denials, which percolate up to the user as scare warnings that the
application was prevented from doing something dangerous and possibly
malicious, when that's not the case at all.


Thanks,
Roland
--
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/