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]
Date:   Wed, 17 Feb 2021 15:49:54 +0000
From:   Chris Down <chris@...isdown.name>
To:     Petr Mladek <pmladek@...e.com>
Cc:     linux-kernel@...r.kernel.org,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        John Ogness <john.ogness@...utronix.de>,
        Johannes Weiner <hannes@...xchg.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kees Cook <keescook@...omium.org>, kernel-team@...com
Subject: Re: debugfs: was: Re: [PATCH v4] printk: Userspace format
 enumeration support

Petr Mladek writes:
>> > > +	debugfs_remove(ps->file);
>> >
>> > IMHO, we should remove the file before we remove the way how
>> > to read it. This should be done in the opposite order
>> > than in store_printk_fmt_sec().
>>
>> There is a subtle issue with doing this as-is: debugfs_remove(ps->file)
>> cannot be called under printk_fmts_mutex, because we may deadlock due to a
>> pinned debugfs refcnt if debugfs_remove() and _show happen at the same time.
>
>Do we need to call debugfs_remove(ps->file) under printk_fmts_mutex?

Ah, my concern was simultaneous entries into remove_printk_fmt_sec (which would 
require setting a separate flag under the mutex), but now I think about it, the 
module notifier synchronously waits, so that can't happen anyway.

As such it should be safe to just do:

remove()
{
	mutex_lock(&printk_fmts_mutex);
	ps = find_printk_fmt_sec();
	mutex_unlock(&printk_fmts_mutex);

	if (!ps)
		return;

	/* waits for _show */
	debugfs_remove(ps->file);

	mutex_lock(&printk_fmts_mutex);
	/* Do the data structure teardown */
	mutex_unlock(&printk_fmts_mutex);
}

Sounds good to me, I'll do that for v5. Thanks! :-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ