From: Andrzej Hajda <andrzej.hajda@intel.com>
To: Javier Martinez Canillas <javierm@redhat.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
<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 00:22:55 +0200 [thread overview]
Message-ID: <fc3e8a40-664f-07ae-7474-c0412a1ab1b5@intel.com> (raw)
In-Reply-To: <2bf27b09-0896-1849-254f-d5b19abdc892@redhat.com>
On 09.05.2022 22:03, Javier Martinez Canillas wrote:
> On 5/9/22 20:12, Thomas Zimmermann wrote:
>
> [snip]
>
>>> I actually thought about the same but then remembered what Daniel said in [0]
>>> (AFAIU at least) that these should be done in .remove() so the current code
>>> looks like matches that and only framebuffer_release() should be moved.
>>>
>>> For vesafb a previous patch proposed to also move a release_region() call to
>>> .fb_destroy() and Daniel also said that it was iffy and shouldn't be done [1].
>>>
>>> But I'm also not fb expert so happy to move fb_dealloc_cmap() as well if that
>>> is the correct thing to do.
>> The cmap data structure is software state that can be accessed via icotl
>> as long as the devfile is open. Drivers update the hardware from it. See
>> [1]. Moving that cleanup into fb_destroy seems appropriate to me.
>>
> I see, that makes sense. Then something like the following instead?
>
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index d265a73313c9..ce0d89c49e42 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -627,12 +627,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
> cancel_work_sync(&fb_helper->resume_work);
> cancel_work_sync(&fb_helper->damage_work);
>
> - info = fb_helper->fbdev;
> - if (info) {
> - if (info->cmap.len)
> - fb_dealloc_cmap(&info->cmap);
> - framebuffer_release(info);
> - }
> fb_helper->fbdev = NULL;
>
> mutex_lock(&kernel_fb_helper_lock);
> @@ -2111,7 +2105,11 @@ static void drm_fbdev_release(struct drm_fb_helper *fb_helper)
> */
> 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.
Regards
Andrzej
> }
>
> static int drm_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
>
next prev parent reply other threads:[~2022-05-09 22:23 UTC|newest]
Thread overview: 30+ 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 [this message]
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
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-08 15:40 ` [fbdev] c6a2b1a999: BUG:KASAN:use-after-free_in_efifb_destroy 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-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=fc3e8a40-664f-07ae-7474-c0412a1ab1b5@intel.com \
--to=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 \
--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®