From: Guenter Roeck <linux@roeck-us.net>
To: Joe Perches <joe@perches.com>, Kees Cook <keescook@chromium.org>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: airlied@gmail.com, dakr@redhat.com, daniel@ffwll.ch,
dri-devel@lists.freedesktop.org, jani.nikula@intel.com,
javierm@redhat.com, kherbst@redhat.com,
linux-kernel@vger.kernel.org, lyude@redhat.com,
mripard@kernel.org, nouveau@lists.freedesktop.org,
tzimmermann@suse.de, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] drm/nouveau/nvif: Avoid build error due to potential integer overflows
Date: Sun, 19 May 2024 07:09:44 -0700 [thread overview]
Message-ID: <bf8af522-d4ee-47cd-82a8-635fc144b648@roeck-us.net> (raw)
In-Reply-To: <03cc262da2a3db817aa5663fbce6c914708b74f8.camel@perches.com>
On 5/18/24 18:19, Joe Perches wrote:
> On Sat, 2024-05-18 at 11:23 -0700, Guenter Roeck wrote:
>> On 5/18/24 10:32, Kees Cook wrote:
>>
> []
>>> 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 though the allocation may not.
>>>
>>> Better yet, since "sizeof(*args) + size" is repeated 3 times in the
>>> function, I'd recommend:
>>>
>>> ...
>>> u32 args_size;
>>>
>>> if (check_add_overflow(sizeof(*args), size, &args_size))
>>> return -ENOMEM;
>>> if (args_size > sizeof(stack)) {
>>> if (!(args = kmalloc(args_size, GFP_KERNEL)))
>
> trivia:
>
> More typical kernel style would use separate alloc and test
>
> args = kmalloc(args_size, GFP_KERNEL);
> if (!args)
>
Sure, I can do that as well. I'll wait a couple of days though before
sending v3 in case there are more change requests.
Guenter
prev parent reply other threads:[~2024-05-19 14:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-18 14:37 Guenter Roeck
2024-05-18 16:54 ` Christophe JAILLET
2024-05-18 17:32 ` Kees Cook
2024-05-18 18:23 ` Guenter Roeck
2024-05-19 1:19 ` Joe Perches
2024-05-19 14:09 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf8af522-d4ee-47cd-82a8-635fc144b648@roeck-us.net \
--to=linux@roeck-us.net \
--cc=airlied@gmail.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dakr@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=javierm@redhat.com \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=kherbst@redhat.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®