linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Javier Martinez Canillas <javierm@redhat.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	linux-kernel@vger.kernel.org
Cc: linux-fbdev@vger.kernel.org,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Helge Deller <deller@gmx.de>,
	dri-devel@lists.freedesktop.org,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()
Date: Tue, 10 May 2022 10:37:48 +0200	[thread overview]
Message-ID: <7ffd92d7-9c07-fa9c-dc95-9e82719fd237@suse.de> (raw)
In-Reply-To: <2d8d8583-3a39-b826-dd83-ba5bc4c5b082@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 2113 bytes --]

Hi

Am 10.05.22 um 10:30 schrieb Javier Martinez Canillas:
> Hello Thomas,
> 
> On 5/10/22 10:04, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 10.05.22 um 00:42 schrieb Javier Martinez Canillas:
>>> On 5/10/22 00:22, Andrzej Hajda wrote:
>>>
>>> [snip]
>>>
>>>>>     static void drm_fbdev_fb_destroy(struct fb_info *info)
>>>>>     {
>>>>> +       if (info->cmap.len)
>>>>> +               fb_dealloc_cmap(&info->cmap);
>>>>> +
>>>>>            drm_fbdev_release(info->par);
>>>>> +       framebuffer_release(info);
>>>>
>>>> I would put drm_fbdev_release at the beginning - it cancels workers
>>>> which could expect cmap to be still valid.
>>>>
>>>
>>> Indeed, you are correct again. [0] is the final version of the patch I've
>>> but don't have an i915 test machine to give it a try. I'll test tomorrow
>>> on my test systems to verify that it doesn't cause any regressions since
>>> with other DRM drivers.
>>
>> You have to go through all DRM drivers that call drm_fb_helper_fini()
>> and make sure that they free fb_info. For example armada appears to be
>> leaking now. [1]
>>
> 
> But shouldn't fb_info be freed when unregister_framebuffer() is called
> through drm_dev_unregister() ? AFAICT the call chain is the following:
> 
> drm_put_dev()
>    drm_dev_unregister()
>      drm_client_dev_unregister()
>        drm_fbdev_client_unregister()
>          drm_fb_helper_unregister_fbi()
>            unregister_framebuffer()
>              do_unregister_framebuffer()
>                put_fb_info()
>                  drm_fbdev_fb_destroy()
>                    framebuffer_release()
> 
> which is the reason why I believe that drm_fb_helper_fini() should be
> an internal static function and only called from drm_fbdev_fb_destroy().
> 
> Drivers shouldn't really explicitly call this helper in my opinion.

Thanks.  That makes sense.

Best regards
Thomas


> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2022-05-10  8:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 21:59 [PATCH v3 0/4] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers Javier Martinez Canillas
2022-05-05 22:04 ` [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release() Javier Martinez Canillas
2022-05-09 14:56   ` Andrzej Hajda
2022-05-09 15:30     ` Javier Martinez Canillas
2022-05-09 15:51       ` Andrzej Hajda
2022-05-09 16:33         ` Javier Martinez Canillas
2022-05-09 18:12           ` Thomas Zimmermann
2022-05-09 20:03             ` Javier Martinez Canillas
2022-05-09 22:22               ` Andrzej Hajda
2022-05-09 22:42                 ` Javier Martinez Canillas
2022-05-10  7:19                   ` Andrzej Hajda
2022-05-10  7:50                     ` Javier Martinez Canillas
2022-05-11 13:18                       ` Daniel Vetter
2022-05-10  8:04                   ` Thomas Zimmermann
2022-05-10  8:30                     ` Javier Martinez Canillas
2022-05-10  8:37                       ` Thomas Zimmermann [this message]
2022-05-10  8:50                         ` Thomas Zimmermann
2022-05-10  9:06                           ` Javier Martinez Canillas
2022-05-10  9:39                             ` Thomas Zimmermann
2022-05-10  9:44                               ` Javier Martinez Canillas
2022-05-09 18:32           ` Thomas Zimmermann
2022-05-09 20:00             ` Javier Martinez Canillas
2022-05-11 13:15               ` Daniel Vetter
2022-05-05 22:04 ` [PATCH v3 2/4] fbdev: simplefb: Cleanup fb_info in .fb_destroy rather than .remove Javier Martinez Canillas
2022-05-05 22:05 ` [PATCH v3 3/4] fbdev: efifb: " Javier Martinez Canillas
2022-05-06 13:07   ` Andrzej Hajda
2022-05-06 13:18     ` Javier Martinez Canillas
2022-05-05 22:06 ` [PATCH v3 4/4] fbdev: vesafb: " Javier Martinez Canillas
2022-05-06  7:34 ` [PATCH v3 0/4] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers Javier Martinez Canillas

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=7ffd92d7-9c07-fa9c-dc95-9e82719fd237@suse.de \
    --to=tzimmermann@suse.de \
    --cc=andrzej.hajda@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).