Re: [PATCH 11/11] Use down_read_critical() for /proc/<pid>/exe and/proc/<pid>/maps files

From: Arjan van de Ven
Date: Thu May 27 2010 - 10:10:21 EST


On Mon, 24 May 2010 13:31:21 -0700
Michel Lespinasse <walken@xxxxxxxxxx> wrote:

> This helps in the following situation:
> - Thread A takes a page fault while reading or writing memory.
> do_page_fault() acquires the mmap_sem for read and blocks on disk
> (either reading the page from file, or hitting swap) for a long
> time.
> - Thread B does an mmap call and blocks trying to acquire the mmap_sem
> for write
> - Thread C is a monitoring process trying to read every /proc/pid/maps
> in the system. This requires acquiring the mmap_sem for read.
> Thread C blocks behind B, waiting for A to release the rwsem. If
> thread C could be allowed to run in parallel with A, it would
> probably get done long before thread A's disk access completes, thus
> not actually slowing down thread B.
>
> Test results with down_read_critical_test (10 seconds):


this is a really bad idea btw

we've had many issues in the past, when this was an unfair lock, that
"top" or other similar things, caused basically a DoS......
now any process that can get to /proc/<pid>/exe or maps, can do this in
a tight enough loop so that the actual process will never get the lock
for write. BAD IDEA ;-)


--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
--
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/