Displaying 4 results from an estimated 4 matches for "size_add".
2024 May 18
1
[PATCH] drm/nouveau/nvif: Avoid build error due to potential integer overflows
...eof(*args) + size > sizeof(stack)) {
> - if (!(args = kmalloc(sizeof(*args) + size, GFP_KERNEL)))
> + if (size > sizeof(stack) - sizeof(*args)) {
> + if (size > INT_MAX ||
> + !(args = kmalloc(sizeof(*args) + size, GFP_KERNEL)))
Hi,
Would it be cleaner or better to use size_add(sizeof(*args), size)?
> return -ENOMEM;
> } else {
> args = (void *)stack;
> @@ -276,7 +277,8 @@ nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle,
> object->map.size = 0;
>
> if (parent) {
> - if (!(args = kmalloc(sizeof(*ar...
2024 May 18
1
[PATCH] drm/nouveau/nvif: Avoid build error due to potential integer overflows
...> > - if (!(args = kmalloc(sizeof(*args) + size, GFP_KERNEL)))
> > + if (size > sizeof(stack) - sizeof(*args)) {
> > + if (size > INT_MAX ||
> > + !(args = kmalloc(sizeof(*args) + size, GFP_KERNEL)))
>
> Hi,
>
> Would it be cleaner or better to use size_add(sizeof(*args), size)?
I think the INT_MAX test is actually better in this case because
nvif_object_ioctl()'s size argument is u32:
ret = nvif_object_ioctl(object, args, sizeof(*args) + size, NULL);
^^^^^^^^^^^^^^^^^^^^
So that could wrap around, even tho...
2024 May 18
1
[PATCH] drm/nouveau/nvif: Avoid build error due to potential integer overflows
...= kmalloc(sizeof(*args) + size, GFP_KERNEL)))
>>> + if (size > sizeof(stack) - sizeof(*args)) {
>>> + if (size > INT_MAX ||
>>> + !(args = kmalloc(sizeof(*args) + size, GFP_KERNEL)))
>>
>> Hi,
>>
>> Would it be cleaner or better to use size_add(sizeof(*args), size)?
>
> I think the INT_MAX test is actually better in this case because
> nvif_object_ioctl()'s size argument is u32:
>
> ret = nvif_object_ioctl(object, args, sizeof(*args) + size, NULL);
> ^^^^^^^^^^^^^^^^^^^^
>...
2024 May 18
1
[PATCH] drm/nouveau/nvif: Avoid build error due to potential integer overflows
Trying to build parisc:allmodconfig with gcc 12.x or later results
in the following build error.
drivers/gpu/drm/nouveau/nvif/object.c: In function 'nvif_object_mthd':
drivers/gpu/drm/nouveau/nvif/object.c:161:9: error:
'memcpy' accessing 4294967264 or more bytes at offsets 0 and 32 overlaps 6442450881 bytes at offset -2147483617 [-Werror=restrict]
161 | memcpy(data,