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: <559420DA.3010401@canonical.com>
Date:	Wed, 01 Jul 2015 18:18:18 +0100
From:	Colin Ian King <colin.king@...onical.com>
To:	Emil Velikov <emil.l.velikov@...il.com>,
	Ilia Mirkin <imirkin@...m.mit.edu>
CC:	Ben Skeggs <bskeggs@...hat.com>,
	"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized

On 01/07/15 18:12, Emil Velikov wrote:
> On 1 July 2015 at 17:56, Ilia Mirkin <imirkin@...m.mit.edu> wrote:
>> On Wed, Jul 1, 2015 at 12:51 PM, Colin King <colin.king@...onical.com> wrote:
>>> From: Colin Ian King <colin.king@...onical.com>
>>>
>>> Various usif_ioctl helper functions do not initialize the
>>> return variable ret and some of the error handling return
>>> paths just return garbage values that were on the stack (or
>>> in a register).  I believe that in all the cases, the
>>> initial ret variable should be set to -EINVAL and subsequent
>>> paths through these helper functions set it appropriately
>>> otherwise.
>>>
>>> Found via static analysis using cppcheck:
>>>
>>> [drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
>>>     (error) Uninitialized variable: ret
>>
>> It sure would seem that way, wouldn't it?
>>
>> #define nvif_unpack(d,vl,vh,m) ({                                              \
>>         if ((vl) == 0 || ret == -ENOSYS) {                                     \
>>                 int _size = sizeof(d);                                         \
>>                 if (_size <= size && (d).version >= (vl) &&                    \
>>                                      (d).version <= (vh)) {                    \
>>                         data = (u8 *)data + _size;                             \
>>                         size = size - _size;                                   \
>>                         ret = ((m) || !size) ? 0 : -E2BIG;                     \
>>                 } else {                                                       \
>>                         ret = -ENOSYS;                                         \
>>                 }                                                              \
>>         }                                                                      \
>>         (ret == 0);                                                            \
>> })
>>
>> So actually it does get initialized, and I guess cppcheck doesn't know
>> about macros?

Hrm, what about the case when ((vl) == 0 || ret == -ENOSYS) is false,
where is ret being set in that case?

>>
> I think I'm having deja-vu, but I do recall a similar mention to Ben.
> Although in my defence I've assumed that nvif_unpack was a function,
> as macros normally are normally all caps. Seems like the patch that
> capitalises nvif_unpack never made it upstream :'-(
> 
> Cheers,
> Emil
> 

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