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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230517152632.GC1286@redhat.com>
Date:   Wed, 17 May 2023 17:26:33 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     Wander Lairson Costa <wander@...hat.com>
Cc:     "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
        Brian Cain <bcain@...cinc.com>,
        Michael Ellerman <mpe@...erman.id.au>,
        Stafford Horne <shorne@...il.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Liam R. Howlett" <Liam.Howlett@...cle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        Andrei Vagin <avagin@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        "Paul E. McKenney" <paulmck@...nel.org>,
        Daniel Bristot de Oliveira <bristot@...nel.org>,
        Yu Zhao <yuzhao@...gle.com>,
        Alexey Gladkov <legion@...nel.org>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Yang Shi <shy828301@...il.com>,
        open list <linux-kernel@...r.kernel.org>,
        Hu Chunyu <chuhu@...hat.com>,
        Valentin Schneider <vschneid@...hat.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Steven Rostedt <rostedt@...dmis.org>,
        Luis Goncalves <lgoncalv@...hat.com>
Subject: Re: [PATCH v9] kernel/fork: beware of __put_task_struct calling
 context

On 05/16, Wander Lairson Costa wrote:
>
>  static inline void put_task_struct(struct task_struct *t)
>  {
> -	if (refcount_dec_and_test(&t->usage))
> +	if (!refcount_dec_and_test(&t->usage))
> +		return;
> +
> +	/*
> +	 * under PREEMPT_RT, we can't call put_task_struct
> +	 * in atomic context because it will indirectly
> +	 * acquire sleeping locks.
> +	 *
> +	 * call_rcu() will schedule delayed_put_task_struct_rcu()
> +	 * to be called in process context.
> +	 *
> +	 * __put_task_struct() is called when
> +	 * refcount_dec_and_test(&t->usage) succeeds.
> +	 *
> +	 * This means that it can't "conflict" with
> +	 * put_task_struct_rcu_user() which abuses ->rcu the same
> +	 * way; rcu_users has a reference so task->usage can't be
> +	 * zero after rcu_users 1 -> 0 transition.
> +	 *
> +	 * delayed_free_task() also uses ->rcu, but it is only called
> +	 * when it fails to fork a process. Therefore, there is no
> +	 * way it can conflict with put_task_struct().
> +	 */
> +	if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible())
> +		call_rcu(&t->rcu, __put_task_struct_rcu_cb);
> +	else
>  		__put_task_struct(t);
>  }

LGTM but we still need to understand the possible problems with CONFIG_PROVE_RAW_LOCK_NESTING ...

Again, I'll try to investigate when I have time although I am not sure I can really help.

Perhaps you too can try to do this ? ;)

Oleg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ