Re: [PATCH 2/2] drm: Prevent drm_copy_field() to attempt copying a NULL pointer

From: Javier Martinez Canillas
Date: Mon Jul 04 2022 - 08:56:12 EST


On 7/4/22 14:36, Javier Martinez Canillas wrote:
> Hello Thomas,
>
> Thanks for your feedback.
>

[snip]

>>> + /* don't attempt to copy a NULL pointer */
>>> + if (WARN_ONCE(!value, "BUG: the value to copy was not set!"))
>>> + return -EINVAL;
>>> +
>>
>> We usually assume that the caller passes the correct arguments. This is
>> different for no reasons. I'd rather not take this patch unless there's
>> a security implication to the ioctl interface (e.g., leaking information
>> because of this NULL ptr).
>>
>
> This can lead from an oops (soft panic) to a kernel crash for a buggy driver.
>
> I see from where you are coming from but then I think we should sanitize the
> filled struct drm_driver fields in drm_dev_register() and make it fail early.
>
> Would you agree with such a patch? But what I think that we shouldn't allow
> is to attempt copying a NULL pointer, if we can easily prevent it.
>

I mean something like the following patch (didn't add a commit message
for brevity):