[PATCH v2 0/1] uprobes: Use percpu_rw_semaphore to fixregister/unregister vs dup_mmap() race

From: Oleg Nesterov
Date: Wed Nov 14 2012 - 13:48:55 EST


Hello.

The same patch I sent before, the only difference is that it uses
percpu_rw_semaphore instead of brw_mutex.

Srikar, I'll hope you can ack v2 too, and unless someone objects
I'll ask Ingo to pull this fix.

Tejun, recently we briefly discussed signal->group_rwsem, please
see the note about cgroups below.

Note:

- The current implementation of percpu_rw_semaphore is not
optimal, register/unregister will block fork() completely
while it sleeps in msleep() and synchronize_sched().

So this patch assumes that

percpu_rw_semaphore-reimplement-to-not-block-the-readers-unnecessarily.patch
http://marc.info/?l=linux-mm-commits&m=135240650828875

will be applied eventually (and the new implementation can be
improved).

- This patch adds percpu_down_read/up_read around dup_mmap()
for uprobes.

Given that it is very cheap (and assuming the optimizations
above), _perhaps_ we can turn this dup_mmap_sem into fork_sem
and use it instead of threadgroup_change_begin/end, so that
uprobes and cgroups can use it.

- Compared to v1, percpu_rw_semaphore doesn't support multi-
writers. I hope we can tolerate this, register/unregister
are system-wide and rare events anyway. And _perhaps_ we
can add percpu_down_write_nonexclusive() later.

- Given that currently percpu_down_write() is exclusive, this
patch almost dismisses the purpose of uprobes_mutex[] array.

Yes, but we need to rework this locking anyway for filtering.

Oleg.

--
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/