Oleg Nesterov 6d08f2c713 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>
2012-02-01 14:39:01 -08:00
..
2012-01-03 22:55:04 -05:00
2012-01-03 22:54:53 -05:00
2012-01-03 22:54:53 -05:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:54:57 -05:00
2012-01-03 22:55:10 -05:00
2012-01-03 22:54:54 -05:00
2012-01-09 10:48:11 -05:00
2012-01-10 13:45:22 -08:00
2012-01-03 22:55:01 -05:00
2012-01-03 22:55:07 -05:00
2012-01-10 13:45:22 -08:00
2012-01-03 22:55:11 -05:00
2012-01-03 22:54:54 -05:00
2011-11-16 09:21:50 +01:00
2012-01-03 22:54:07 -05:00
2012-01-12 20:13:04 -08:00
2012-01-03 22:52:39 -05:00
2012-01-17 16:39:47 -05:00
2012-01-05 15:40:12 -08:00
2012-01-03 22:54:07 -05:00
2011-10-31 17:30:44 -07:00
2012-01-03 22:52:40 -05:00
2012-01-03 22:54:07 -05:00
2011-11-02 12:53:43 +01:00
2012-01-03 22:53:07 -05:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:52:40 -05:00