From: Tim Gardner <tim.gardner@canonical.com>
To: "Bruno Prémont" <bonbons@linux-vserver.org>
Cc: linux-fbdev@vger.kernel.org, lethal@linux-sh.org,
linux-kernel@vger.kernel.org,
Andy Whitcroft <andy.whitcroft@canonical.com>
Subject: Re: [PATCH V3] fbcon -- fix race between open and removal of framebuffers
Date: Wed, 11 May 2011 14:09:29 +0000 [thread overview]
Message-ID: <4DCA9899.6070403@canonical.com> (raw)
In-Reply-To: <20110510234424.5a5b7a08@neptune.home>
On 05/10/2011 11:44 PM, Bruno Prémont wrote:
> On Tue, 10 May 2011 Tim Gardner<tim.gardner@canonical.com> wrote:
>> From ca3ef33e2235c88856a6257c0be63192ab56c678 Mon Sep 17 00:00:00 2001
>> From: Andy Whitcroft<apw@canonical.com>
>> Date: Thu, 29 Jul 2010 16:48:20 +0100
>> Subject: [PATCH] fbcon -- fix race between open and removal of framebuffers
>>
>> Currently there is no locking for updates to the registered_fb list.
>> This allows an open through /dev/fbN to pick up a registered framebuffer
>> pointer in parallel with it being released, as happens when a conflicting
>> framebuffer is ejected or on module unload. There is also no reference
>> counting on the framebuffer descriptor which is referenced from all open
>> files, leading to references to released or reused memory to persist on
>> these open files.
>>
>> This patch adds a reference count to the framebuffer descriptor to prevent
>> it from being released until after all pending opens are closed. This
>> allows the pending opens to detect the closed status and unmap themselves.
>> It also adds locking to the framebuffer lookup path, locking it against
>> the removal path such that it is possible to atomically lookup and take a
>> reference to the descriptor. It also adds locking to the read and write
>> paths which currently could access the framebuffer descriptor after it
>> has been freed. Finally it moves the device to FBINFO_STATE_REMOVED to
>> indicate that all access should be errored for this device.
>
> What framebuffer drivers was this patch tested with? Just x86 with
> mainstream GPU (intel/amd/nvidia KMS) in compination with vgafb/vesafb or
> did it see some testing with other framebuffers like those from embedded
> world?
>
This patch is also in all of the armel (OMAP3/OMAP4) kernels.
> Otherwise a much smaller (memory leaking) patch would be to just change
> vesafb/vgafb to not free their fb_info after unregistration as was suggested
> by Alan Cox.
>
Sure, I suppose thats possible, but this is the patch that I have working.
<snip>
>
> This only partially protects the list and count as two concurrent
> framebuffer registrations do still race against each other.
> For the issue addressed by this patch I don't think it makes sense to
> have this spinlock at all as it's only used in get_framebuffer_info()
> and in put_framebuffer_info() and put_framebuffer_info() doesn't even
> look at registered_fb or num_registered_fb.
> Such a spinlock makes sense in a separate patch that really protects
> all access to registered_fb or num_registered_fb, be it during framebuffer
> (un)registration or during access from fbcon.
>
Our goal was merely to stop the user space open/close races. I agree
that the framebuffer registration list needs more orthogonal protection,
but that is going to be a much larger patch.
rtg
--
Tim Gardner tim.gardner@canonical.com
next prev parent reply other threads:[~2011-05-11 14:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 17:41 [PATCH 0/1] fbcon -- fix race between open and removal of framebuffers tim.gardner
2011-05-05 17:41 ` [PATCH] " tim.gardner
2011-05-05 18:30 ` [PATCH] fbcon -- fix race between open and removal of Bruno Prémont
2011-05-05 21:00 ` [PATCH] fbcon -- fix race between open and removal of framebuffers Jack Stone
2011-05-06 1:09 ` Anca Emanuel
2011-05-06 1:44 ` [PATCH] fbcon -- fix race between open and removal of Greg KH
2011-05-10 12:47 ` [PATCH V2] fbcon -- fix race between open and removal of framebuffers Tim Gardner
2011-05-10 21:06 ` Jack Stone
2011-05-10 21:08 ` Jack Stone
2011-05-06 0:21 ` [PATCH] " Anca Emanuel
2011-05-10 13:52 ` [PATCH V3] " Tim Gardner
2011-05-10 21:44 ` [PATCH V3] fbcon -- fix race between open and removal of Bruno Prémont
2011-05-11 14:09 ` Tim Gardner [this message]
2011-05-11 14:27 ` Bruno Prémont
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=4DCA9899.6070403@canonical.com \
--to=tim.gardner@canonical.com \
--cc=andy.whitcroft@canonical.com \
--cc=bonbons@linux-vserver.org \
--cc=lethal@linux-sh.org \
--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).