lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <29eaed4d-c4e5-cf9b-113b-da146b719820@huawei.com>
Date: Tue, 9 Jan 2024 19:28:29 +0800
From: Yang Jihong <yangjihong1@...wei.com>
To: Chen Zhongjin <chenzhongjin@...wei.com>, <linux-kernel@...r.kernel.org>,
	<linux-trace-kernel@...r.kernel.org>
CC: <naveen.n.rao@...ux.ibm.com>, <anil.s.keshavamurthy@...el.com>,
	<davem@...emloft.net>, <paulmck@...nel.org>, <mhiramat@...nel.org>,
	<akpm@...ux-foundation.org>, <tglx@...utronix.de>, <peterz@...radead.org>,
	<pmladek@...e.com>, <dianders@...omium.org>, <npiggin@...il.com>,
	<mpe@...erman.id.au>, <jkl820.git@...il.com>,
	<juerg.haefliger@...onical.com>, <rick.p.edgecombe@...el.com>,
	<eric.devolder@...cle.com>, <mic@...ikod.net>
Subject: Re: [RFC PATCH] kprobes: Use synchronize_rcu_tasks_rude in
 kprobe_optimizer

Hello,

PING.

I had a similar problem. Is this solution feasible?

Thanks,
Yang

On 2024/1/2 11:40, Chen Zhongjin wrote:
> There is a deadlock scenario in kprobe_optimizer():
> 
> pid A				pid B			pid C
> kprobe_optimizer()		do_exit()		perf_kprobe_init()
> mutex_lock(&kprobe_mutex)	exit_tasks_rcu_start()	mutex_lock(&kprobe_mutex)
> synchronize_rcu_tasks()		zap_pid_ns_processes()	// waiting kprobe_mutex
> // waiting tasks_rcu_exit_srcu	kernel_wait4()
> 				// waiting pid C exit
> 
> To avoid this deadlock loop, use synchronize_rcu_tasks_rude() in kprobe_optimizer()
> rather than synchronize_rcu_tasks(). synchronize_rcu_tasks_rude() can also promise
> that all preempted tasks have scheduled, but it will not wait tasks_rcu_exit_srcu.
> 
> Signed-off-by: Chen Zhongjin <chenzhongjin@...wei.com>
> ---
>   arch/Kconfig     | 2 +-
>   kernel/kprobes.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index f4b210ab0612..dc6a18854017 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -104,7 +104,7 @@ config STATIC_CALL_SELFTEST
>   config OPTPROBES
>   	def_bool y
>   	depends on KPROBES && HAVE_OPTPROBES
> -	select TASKS_RCU if PREEMPTION
> +	select TASKS_RUDE_RCU
>   
>   config KPROBES_ON_FTRACE
>   	def_bool y
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index d5a0ee40bf66..09056ae50c58 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -623,7 +623,7 @@ static void kprobe_optimizer(struct work_struct *work)
>   	 * Note that on non-preemptive kernel, this is transparently converted
>   	 * to synchronoze_sched() to wait for all interrupts to have completed.
>   	 */
> -	synchronize_rcu_tasks();
> +	synchronize_rcu_tasks_rude();
>   
>   	/* Step 3: Optimize kprobes after quiesence period */
>   	do_optimize_kprobes();
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ