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:	Thu, 4 Sep 2014 16:40:11 +0200
From:	Frans Klaver <fransklaver@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	Darren Hart <dvhart@...radead.org>,
	Corentin Chary <corentin.chary@...il.com>,
	Matthew Garrett <matthew.garrett@...ula.com>,
	acpi4asus-user <acpi4asus-user@...ts.sourceforge.net>,
	platform-driver-x86 <platform-driver-x86@...r.kernel.org>,
	linux-kernel@...r.kernel.org, Paul Bolle <pebolle@...cali.nl>
Subject: Re: [PATCH] eeepc-laptop: remove possible use of uninitialized value

On Thu, Sep 4, 2014 at 4:10 PM, Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
> On Thu, Sep 04, 2014 at 08:46:40AM +0200, Frans Klaver wrote:
>> On Thu, Sep 4, 2014 at 3:14 AM, Greg Kroah-Hartman
>> <gregkh@...uxfoundation.org> wrote:
>> > On Wed, Sep 03, 2014 at 05:49:47PM -0700, Darren Hart wrote:
>> >> On Thu, Sep 04, 2014 at 12:53:25AM +0200, Frans Klaver wrote:
>> >> > In store_sys_acpi, if count equals zero, or parse_arg()s sscanf call
>> >> > fails, 'value' remains possibly uninitialized. In that case 'value'
>> >> > shouldn't be used to produce the store_sys_acpi()s return value.
>>
>> Here I should probably remove either 'the' or the 's' after store_sys_acpi().
>>
>>
>> >> > Only test the return value of set_acpi() if we can actually call it.
>> >> > Return rv otherwise.
>> >> >
>> >> > Signed-off-by: Frans Klaver <fransklaver@...il.com>
>> >> > ---
>> >> >  drivers/platform/x86/eeepc-laptop.c | 8 ++++----
>> >> >  1 file changed, 4 insertions(+), 4 deletions(-)
>> >> >
>> >> > diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
>> >> > index bd533c2..41f12ba 100644
>> >> > --- a/drivers/platform/x86/eeepc-laptop.c
>> >> > +++ b/drivers/platform/x86/eeepc-laptop.c
>> >> > @@ -279,10 +279,10 @@ static ssize_t store_sys_acpi(struct device *dev, int cm,
>> >> >     int rv, value;
>> >> >
>> >> >     rv = parse_arg(buf, count, &value);
>> >> > -   if (rv > 0)
>> >> > -           value = set_acpi(eeepc, cm, value);
>> >>
>> >> That was rather horrible wasn't it? :-)
>> >>
>> >> > -   if (value < 0)
>> >> > -           return -EIO;
>> >> > +   if (rv > 0) {
>> >> > +           if (set_acpi(eeepc, cm, value) < 0)
>> >> > +                   return -EIO;
>> >>
>> >> Is there a compelling reason not to propogate the return code of set_acpi?
>> >> (ENODEV specifically). I see -EIO in Documentation/filesystems/sysfs.txt, but
>> >> it's used by default if the show() pointer is NULL (for example), but otherwise
>> >> propogates the error.
>> >>
>> >> Specifically it states:
>> >>
>> >> - show() or store() can always return errors. If a bad value comes
>> >>   through, be sure to return an error.
>> >>
>> >> Greg, does this need to be -EIO? or is returning someting like ENODEV preferable
>> >> if it more accurately reflects the error?
>> >
>> > Just return the value of set_acpi() and you should be fine.
>>
>> According to 6dff29b63a5bf2eaf3313cb8a84f0b7520c43401 "eeepc-laptop:
>> disp attribute should be write-only" it should be -EIO. -ENODEV would
>> be misleading.
>
> If something is "write only" then there should not be a store function
> for it at all, the file should not be marked as writable, to prevent
> anything from ever being written to it at the higher-level filesystem
> layer, and never get down to the driver layer...

If something is "write only" it should not have a show function.
Removing the show function for the disp attribute would probably also
remove the necessity for the file permissions.

I'll I fire up my eeepc and see what I can figure out. Should I take
Pauls patch and see how it fits into this?

Thanks,
Frans
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ