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: <Z2QxQhvserbVvmrB@pathway.suse.cz>
Date: Thu, 19 Dec 2024 15:44:18 +0100
From: Petr Mladek <pmladek@...e.com>
To: Rob Herring <robh@...nel.org>
Cc: Steven Rostedt <rostedt@...dmis.org>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Jonathan Corbet <corbet@....net>,
	Saravana Kannan <saravanak@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Zijun Hu <quic_zijuhu@...cinc.com>, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: ssize_t: was: Re: [PATCH] of: Add printf '%pOFm' for generating
 modalias

On Wed 2024-12-18 11:10:54, Rob Herring wrote:
> On Wed, Dec 18, 2024 at 5:35 AM Petr Mladek <pmladek@...e.com> wrote:
> >
> > On Tue 2024-12-17 12:37:09, Rob Herring (Arm) wrote:
> > > The callers for of_modalias() generally need the module alias as part of
> > > some larger string. That results in some error prone manipulation of the
> > > buffer prepend/append the module alias string. In fact,
> > > of_device_uevent_modalias() has several issues. First, it's off by one
> > > too few characters in utilization of the full buffer. Second, the error
> > > paths leave OF_MODALIAS with a truncated value when in the end nothing
> > > should be added to the buffer. It is also fragile because it needs
> > > internal details of struct kobj_uevent_env. add_uevent_var() really
> > > wants to write the env variable and value in one shot which would need
> > > either a temporary buffer for value or a format specifier.
> > >
> > > Fix these issues by adding a new printf format specifier, "%pOFm". With
> > > the format specifier in place, simplify all the callers of
> > > of_modalias(). of_modalias() can also be simplified with vsprintf()
> > > being the only caller as it avoids the error conditions.
> > >
> > > --- a/drivers/of/module.c
> > > +++ b/drivers/of/module.c
> > > @@ -8,21 +8,14 @@
> > >  #include <linux/slab.h>
> > >  #include <linux/string.h>
> > >
> > > -ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
> > > +/* Do not use directly, use %pOFm format specifier instead */
> > > +size_t of_modalias(const struct device_node *np, char *str, size_t len)
> >
> > We should keep ssize_t.
> 
> My intent was to align of_modalias() with snprintf()...

Sure.

> > "end - buf" passed from device_node_string() in vprintf.c might be
> > negative. The "buf" pointer is used to count the number of characters
> > which might be written when the buffer is big enough.
> 
> Isn't Rasmus' suggestion sufficient?:
> 
> buf += of_modalias(dn, buf, buf < end ? end - buf : 0)

Yes, this should do the trick. I sent my overview before reading
Rasmus' reply.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ