All of lore.kernel.org
 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: Daniel Vetter <daniel.vetter@ffwll.ch>,
	linux-fbdev@vger.kernel.org, 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 11:39:37 +0200	[thread overview]
Message-ID: <23ae6eaa-c281-9fc1-2c64-dd953ad2f5f1@suse.de> (raw)
In-Reply-To: <35ffd96d-3cbe-12dd-c1ea-878299ec173c@redhat.com>


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

Hi Javier

Am 10.05.22 um 11:06 schrieb Javier Martinez Canillas:
> Hello Thomas,
> 
> On 5/10/22 10:50, Thomas Zimmermann wrote:
> 
> [snip]
> 
>>>> Drivers shouldn't really explicitly call this helper in my opinion.
>>
>> One more stupid question: does armada actually use
>> drm_fbdev_fb_destroy()? It's supposed to be a callback for struct
>> fb_ops. Armada uses it's own instance of fb_ops, which apparently
>> doesn't contain fb_destroy. [1]
>>
> 
> No stupid question at all. You are correct on this. So I guess we still
> need this call in the drivers that don't provide a .fb_destroy() handler.
> 
> I see many options here:
> 
> 1) Document in drm_fb_helper_alloc_fbi() that drivers only need to call
>     drm_fb_helper_fini() explicitly if they are not setting up a fbdev
>     with drm_fbdev_generic_setup(), otherwise is not needed.
> 
> 2) Make drm_fbdev_fb_destroy() an exported symbol so drivers that have
>     custom fb_ops can use it.
> 
> 3) Set .fb_destroy to drm_fbdev_fb_destroy() if isn't set by drivers when
>     they call drm_fb_helper_initial_config() or drm_fb_helper_fill_info().
> 
> I'm leaning towards option (3). Then the fb_info release will be automatic
> whether drivers are using the generic setup or a custom one.

IMHO this would just be another glitch to paper over all the broken 
code. And if you follow through drm_fbdev_fb_helper(), [1] it'll call 
_fini at some point and probably blow up in some other way. Instances of 
struct fb_ops are also usually const.

The only reliable way AFAICT is to do what generic fbdev does: use 
unregister_framebuffer and do the software cleanup somewhere within 
fb_destroy. And then fix all drivers to use that pattern.

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v5.17.6/source/drivers/gpu/drm/drm_fb_helper.c#L2082

> 

-- 
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  9:39 UTC|newest]

Thread overview: 56+ 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 21:59 ` 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-05 22:04   ` Javier Martinez Canillas
2022-05-09 14:56   ` Andrzej Hajda
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 15:51         ` Andrzej Hajda
2022-05-09 16:33         ` Javier Martinez Canillas
2022-05-09 18:12           ` Thomas Zimmermann
2022-05-09 18:12             ` Thomas Zimmermann
2022-05-09 20:03             ` Javier Martinez Canillas
2022-05-09 20:03               ` Javier Martinez Canillas
2022-05-09 22:22               ` Andrzej Hajda
2022-05-09 22:22                 ` Andrzej Hajda
2022-05-09 22:42                 ` Javier Martinez Canillas
2022-05-09 22:42                   ` Javier Martinez Canillas
2022-05-10  7:19                   ` Andrzej Hajda
2022-05-10  7:19                     ` Andrzej Hajda
2022-05-10  7:50                     ` Javier Martinez Canillas
2022-05-10  7:50                       ` Javier Martinez Canillas
2022-05-11 13:18                       ` Daniel Vetter
2022-05-11 13:18                         ` Daniel Vetter
2022-05-10  8:04                   ` Thomas Zimmermann
2022-05-10  8:04                     ` Thomas Zimmermann
2022-05-10  8:30                     ` Javier Martinez Canillas
2022-05-10  8:30                       ` Javier Martinez Canillas
2022-05-10  8:37                       ` Thomas Zimmermann
2022-05-10  8:37                         ` Thomas Zimmermann
2022-05-10  8:50                         ` Thomas Zimmermann
2022-05-10  8:50                           ` Thomas Zimmermann
2022-05-10  9:06                           ` Javier Martinez Canillas
2022-05-10  9:06                             ` Javier Martinez Canillas
2022-05-10  9:39                             ` Thomas Zimmermann [this message]
2022-05-10  9:44                               ` Javier Martinez Canillas
2022-05-09 18:32           ` Thomas Zimmermann
2022-05-09 18:32             ` Thomas Zimmermann
2022-05-09 20:00             ` Javier Martinez Canillas
2022-05-09 20:00               ` Javier Martinez Canillas
2022-05-11 13:15               ` Daniel Vetter
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:04   ` Javier Martinez Canillas
2022-05-05 22:05 ` [PATCH v3 3/4] fbdev: efifb: " Javier Martinez Canillas
2022-05-05 22:05   ` Javier Martinez Canillas
2022-05-06 13:07   ` Andrzej Hajda
2022-05-06 13:07     ` Andrzej Hajda
2022-05-06 13:18     ` Javier Martinez Canillas
2022-05-08 15:40   ` [fbdev] c6a2b1a999: BUG:KASAN:use-after-free_in_efifb_destroy kernel test robot
2022-05-08 15:40     ` kernel test robot
2022-05-08 15:40     ` kernel test robot
2022-05-05 22:06 ` [PATCH v3 4/4] fbdev: vesafb: Cleanup fb_info in .fb_destroy rather than .remove Javier Martinez Canillas
2022-05-05 22:06   ` 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
2022-05-06  7:34   ` 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=23ae6eaa-c281-9fc1-2c64-dd953ad2f5f1@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.