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:	Sat, 24 Jan 2015 00:38:07 +0100
From:	Hartmut Knaack <knaack.h@....de>
To:	"Pandruvada, Srinivas" <srinivas.pandruvada@...el.com>,
	"Baluta, Daniel" <daniel.baluta@...el.com>
CC:	"lars@...afoo.de" <lars@...afoo.de>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"jic23@...nel.org" <jic23@...nel.org>,
	"Purdila, Octavian" <octavian.purdila@...el.com>,
	"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
	"Westerberg, Mika" <mika.westerberg@...el.com>,
	"pmeerw@...erw.net" <pmeerw@...erw.net>,
	"beomho.seo@...sung.com" <beomho.seo@...sung.com>,
	"gwendal@...omium.org" <gwendal@...omium.org>
Subject: Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized

Pandruvada, Srinivas schrieb am 19.01.2015 um 17:56:
> On Mon, 2015-01-19 at 18:49 +0200, Daniel Baluta wrote: 
>> On Mon, Jan 19, 2015 at 6:44 PM, Pandruvada, Srinivas
>> <srinivas.pandruvada@...el.com> wrote:
>>> On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
>>>> Hello,
>>>>
>>>> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
>>>> <srinivas.pandruvada@...el.com> wrote:
>>>>> +Mika
>>>>>
>>>>> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
>>>>>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
>>>>>>> On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@....de> wrote:
>>>>>>>> Daniel Baluta schrieb am 18.12.2014 um 18:16:
>>>>>>>>> When using ACPI, if acpi_match_device fails then chipset enum will be
>>>>>>>>> uninitialized and &ak_def_array[chipset] will point to some bad address.
>>>>>>>>>
>>>>>> I am missing something. You are enumerated over i2c device, which was
>>>>>> created from ACPI PNP resource. There is a valid handle or and the
>>>>>> device has an ACPI companion at the least. If this failing, I have to
>>>>>> check the code for acpi i2c.
>>>>>> Can you check why this check failed? We may have bug in i2c handling.
>>>>
>>>> You are right about this. Under normal circumstances, if probe is called
>>>> then acpi_match_device will not fail. I even tried to remove the
>>>> device after probe
>>>> but before acpi_match_device, anyhow acpi_match_device was still successful :)
>>>>
>>>> This is more a matter of code correctness.
>>>>
>>>> In ak8975_match_acpi_device we have:
>>>>
>>>> »       const struct acpi_device_id *id;
>>>>
>>>> »       id = acpi_match_device(dev->driver->acpi_match_table, dev);
>>>> »       if (!id)
>>>> »       »       return NULL;
>>>> »       *chipset = (int)id->driver_data;
>>>>
>>>> Compiler complains on the fact that chipset might be uninitialized
>>>> if this returns NULL, and we shouldn't ignore this warning even this case
>>>> will never happen.
>>>>
>>> Will this fix?
>>> data->chipset = AK8975;
>>> before
>>> ak8975_match_acpi_device(&client->dev, &data->chipset);
>>>

This would fix the compiler warning, but doesn't seem the right solution for
this issue. Quoting the description of acpi_match_device:
"Return a pointer to the first matching ID on success or %NULL on failure."
So, even if it is very unlikely to for it to fail - if it does fail, the
error should be handled as quick as possible. I would favor Daniels solution
to check for a valid assignment of name.

>>
>> Yes, this is done in the original patch:
>>
>> +       *chipset = AK_MAX_TYPE;
> Since data memory is not zero alloced, other member of data are anyway
> initialized, so adding this also may be better. 

If there did not occur an error condition, it will be assigned a value
before being checked for valid ranges. And if there is an error, probe
should be aborted, anyway. So initializing *chipset doesn't seem to add
any benefit IMHO.

>>
>> .. and fixes the warning.
>>
>> Daniel.
> 
> N�����r��y���b�X��ǧv�^�)޺{.n�+����{��*"��^n�r���z�.��h����&��.�G���h�.(�階�ݢj"��.�.m�����z�ޖ���f���h���~�mml==
> 

--
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