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: <Zz34GgmFbuZKQOzG@pathway.suse.cz>
Date: Wed, 20 Nov 2024 15:54:18 +0100
From: Petr Mladek <pmladek@...e.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Chris Down <chris@...isdown.name>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	Tony Lindgren <tony.lindgren@...ux.intel.com>, kernel-team@...com
Subject: Re: [PATCH v6 06/11] printk: console: Introduce sysfs interface for
 per-console loglevels

On Wed 2024-11-20 09:49:08, John Ogness wrote:
> On 2024-11-20, Chris Down <chris@...isdown.name> wrote:
> >>> +static ssize_t loglevel_show(struct device *dev, struct device_attribute *attr,
> >>> +			     char *buf)
> >>> +{
> >>> +	struct console *con = dev_get_drvdata(dev);
> >>> +
> >>> +	return sysfs_emit(buf, "%d\n", READ_ONCE(con->level));
> >>
> >>While I admire the use of READ_ONCE() properly, it really doesn't matter
> >>for sysfs as it could change right afterwards and no one cares.  So no
> >>need for that here, right?
> >
> > From my reading of the code it looks like we need this to avoid
> > tearing.
> 
> I cannot imagine that any compiler would perform multiple reads to read
> an aligned field of 4-bytes. Particularly since this function only reads
> this one field.

I believe that the chance is very very small. But are you 100% sure, please?

Honestly, it seems that everyone agrees that the READ_ONCE() makes
some sense. I do not understand why some many people wants to remove
it. I personally prefer to be on the safe side.

> At most it is kind of annotating lockless access to con->level. But
> since it is not using data_race(), it would still trigger KCSAN with a
> warning. I recommend removing it.

I actually suggested to make a wrapper similar to
console_srcu_read_flags() and use the data_race() there, see
https://lore.kernel.org/r/Zy4368zf-sJyyzja@pathway.suse.cz

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ