Re: Patch "kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y" has been added to the 3.18-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 6 Dec 2017 23:37:50 +0000
alexander.levin@xxxxxxxxxxx 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@xxxxxxxxxxxxxxxxxxx> 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-3Dlinux_kernel_git_stable_stable-2Dqueue.git-3Ba-3Dsummary&d=DwICAg&c=udBTRvFvXC5Dhqg7UHpJlPps3mZ3LRxpb6__0PomBTQ&r=bUtaaC9mlBij4OjEG_D-KPul_335azYzfC4Rjgomobo&m=9-cmq2QbY49vsZXgMeNFamBo1WYKlpsVWfgnFtvHoG8&s=-feM_ZVFHDeIovYdEj2VhiuNt29qe-U1JXSuc-31dAA&e=
> >>
> >> 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@xxxxxxxxxxxxxxx> 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,


-- 
Masami Hiramatsu <mhiramat@xxxxxxxxxx>



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]