On Thu, Dec 07, 2017 at 02:54:58PM +0900, Masami Hiramatsu wrote:
On Wed, 6 Dec 2017 23:37:50 +0000 alexander.levin@verizon.com wrote:
On Thu, Dec 07, 2017 at 08:27:37AM +0900, Masami Hiramatsu wrote:
Hi Greg,
On Tue, 05 Dec 2017 18:30:54 +0100 gregkh@linuxfoundation.org wrote:
This is a note to let you know that I've just added the patch titled
kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y
to the 3.18-stable tree which can be found at: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kernel.org_git_-3Fp-...
The filename of the patch is: kprobes-use-synchronize_rcu_tasks-for-optprobe-with-config_preempt-y.patch and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let stable@vger.kernel.org know about it.
This is not for bugfix, but improvement. And also, it depends on TASKS_RCU & commit 7e42776d5ed1fe9a941ed8876c5d15cd7cf5d89f.
So, please don't pull it on stable tree.
Thanks for the clarification.
Just to help me understand this better, what I understood from the patch is that we might execute freed trampoline memory, is that not the case here?
No, the patch is only for PREEMPT kernel. Without the patch, PREEMPT kernel disables optprobe itself. On the other hand, non preempt kernel enables optprobe but it uses synchronize_sched() for waiting quiesense period, so that all interrupt routines are done and optprobe can free the trampoline memory safely.
Note that non preempt kernel doesn't preempt tasks, it only interrupts tasks and return soon (without task switching). But PREEMPT kernel can preempt a task, this means a task can be interrupted and switched to other task on the way of execution on trampoline memory. This requires synchronize_rcu_tasks() to wait for switching back to the preempted tasks.
The commit 7e42776d5ed exposes synchronize_rcu_tasks() as a alias of synchronize_sched() when PREEMPT=n.
Thank you,
Thank you for the explanation Masami!
-- Masami Hiramatsu mhiramat@kernel.org