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: <YyGfvzlCu9qgtgA0@smile.fi.intel.com>
Date:   Wed, 14 Sep 2022 12:32:47 +0300
From:   Andy Shevchenko <andriy.shevchenko@...el.com>
To:     "Farber, Eliav" <farbere@...zon.com>
Cc:     jdelvare@...e.com, linux@...ck-us.net, robh+dt@...nel.org,
        p.zabel@...gutronix.de, rtanwar@...linear.com,
        linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, hhhawa@...zon.com, jonnyc@...zon.com
Subject: Re: [PATCH v5 20/21] hwmon: (mr75203) add debugfs to read and write
 temperature coefficients

On Wed, Sep 14, 2022 at 07:26:36AM +0300, Farber, Eliav wrote:
> On 9/13/2022 8:01 PM, Andy Shevchenko wrote:
> > On Tue, Sep 13, 2022 at 05:40:16PM +0300, Farber, Eliav wrote:
> > > On 9/13/2022 4:06 PM, Farber, Eliav wrote:

...

> > > It seems like debugfs_attr_write() calls simple_attr_write() and it uses
> > > kstrtoull(), which is why it fails when setting a negative value.
> > > This is the same also in v6.0-rc5.
> > > 
> > > debugfs_attr_read() on the other hand does show the correct value also
> > > when j is negative.
> > 
> > Which puzzles me since there is a few drivers that use %lld.
> > Yeah, changing it to
> > 
> >        ret = sscanf(attr->set_buf, attr->fmt, &val);
> >        if (ret != 1)
> >                ret = -EINVAL;
> > 
> > probably can fix that. Dunno if debugfs maintainer is okay with this.
> > 
> > P.S. This needs revisiting all format strings to see if there are no
> > additional
> > characters, otherwise that needs to be addressed first, if feasible.
> 
> I was thinking of making such a correction:
> 
> -       ret = kstrtoull(attr->set_buf, 0, &val);
> +       if (attr->set_buf[0] == '-')
> +               ret = kstrtoll(attr->set_buf, 0, &val);
> +       else
> +               ret = kstrtoull(attr->set_buf, 0, &val);
> 
> and when I tested the change it worked, but then I noticed this commit:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/libfs.c?h=v6.0-rc5&id=488dac0c9237647e9b8f788b6a342595bfa40bda
> 
> According to this, it previously used simple_strtoll() which supports
> negative values, but was changed to use kstrtoull() to deliberately
> return '-EINVAL' if it gets a negative value.
> 
> So I’m not sure debugfs maintainers will be okay with a fix that
> basically reverts the commit I mentioned.
> Hence, what do you suggest to do with my commit?
> Is it ok to leave it as it is today?

Meanwhile asking is not a problem, at least we will know for sure.
And yes, leave it as is, but point to the thread where you asking
the clarification.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ