]> www.infradead.org Git - users/jedix/linux-maple.git/commit
proc: make sure mem_open() doesn't pin the target's memory
authorOleg Nesterov <oleg@redhat.com>
Tue, 31 Jan 2012 16:15:11 +0000 (17:15 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Tue, 6 Mar 2012 22:02:02 +0000 (14:02 -0800)
commit057991abd404fec0703c8e78690ff505d22f9538
tree3c5e73f83432e8eca4fea1e7064ead371e424f44
parent23a2cc44984f96cd82925e2f8de7ce4c9fc8e0bd
proc: make sure mem_open() doesn't pin the target's memory

Once /proc/pid/mem is opened, the memory can't be released until
mem_release() even if its owner exits.

Change mem_open() to do atomic_inc(mm_count) + mmput(), this only
pins mm_struct. Change mem_rw() to do atomic_inc_not_zero(mm_count)
before access_remote_vm(), this verifies that this mm is still alive.

I am not sure what should mem_rw() return if atomic_inc_not_zero()
fails. With this patch it returns zero to match the "mm == NULL" case,
may be it should return -EINVAL like it did before e268337d.

Perhaps it makes sense to add the additional fatal_signal_pending()
check into the main loop, to ensure we do not hold this memory if
the target task was oom-killed.

Cc: stable@kernel.org
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 6d08f2c7139790c268820a2e590795cb8333181a)

For Oracle bug 13811116
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
fs/proc/base.c