]> sourceware.org Git - systemtap.git/commit
CVE-2011-2503: read instead of mmap to load modules
authorJosh Stone <jistone@redhat.com>
Mon, 25 Jul 2011 15:48:31 +0000 (11:48 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Mon, 25 Jul 2011 15:49:30 +0000 (11:49 -0400)
commited51cfa24ca27746ab09b59280b94117dd58cba3
tree6f90c41ea3081b203c295f287889d9f58085e4bf
parent4ecaadf545a729bb3e5f01f6f019716d49815d9a
CVE-2011-2503: read instead of mmap to load modules

As staprun is preparing to load a kernel module, we first mmap the whole
module as MAP_PRIVATE. Then we proceed with our security checks,
including a trusted-signature validation on the mapped region, and if
all checks out, we'll call init_module() with that same mapped region.

However, MMAP(2) says of MAP_PRIVATE, "It is unspecified whether changes
made to the file after the mmap() call are visible in the mapped
region."  From my testing, it appears that file changes do indeed show
up in our mapped memory.  This means we have a TOCTOU race between
verifying the signature of that memory and then calling init_module().

By using read() instead of mmap(), we ensure that we have a fully
private copy of the module to verify and load, without fear of change.
runtime/staprun/staprun_funcs.c
This page took 0.028213 seconds and 5 git commands to generate.