]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipc/shm.c: fix overly aggressive shmdt() when calls span multiple segments
authorDave Hansen <dave.hansen@linux.intel.com>
Sat, 13 Dec 2014 00:58:19 +0000 (16:58 -0800)
committerJiri Slaby <jslaby@suse.cz>
Thu, 9 Apr 2015 11:14:25 +0000 (13:14 +0200)
commita540d0b8efe895a738793c1f08b6eec12df0bf7c
treeb6eaaa595bc6eaddc3b01be71e7698879f8a1f9e
parentdd06a9623b7e811b362f248bfc1d3886b0e8add1
ipc/shm.c: fix overly aggressive shmdt() when calls span multiple segments

commit d3c97900b427b8d5a476fdfe484267f09df418d6 upstream.

This is a highly-contrived scenario.  But, a single shmdt() call can be
induced in to unmapping memory from mulitple shm segments.  Example code
is here:

http://www.sr71.net/~dave/intel/shmfun.c

The fix is pretty simple: Record the 'struct file' for the first VMA we
encounter and then stick to it.  Decline to unmap anything not from the
same file and thus the same segment.

I found this by inspection and the odds of anyone hitting this in practice
are pretty darn small.

Lightly tested, but it's a pretty small patch.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
ipc/shm.c