Re: [Linux-fbdev-devel] [2.6.29-rc2] fb_mmap: circular lockingdependency on hibernation

From: Geert Uytterhoeven
Date: Sat Jan 31 2009 - 12:45:10 EST


On Sat, 31 Jan 2009, Andrea Righi wrote:
> On 2009-01-30 05:15, Andrey Borzenkov wrote:
> > On 29 of January 2009 12:10:11 Geert Uytterhoeven wrote:
> >> On Tue, 27 Jan 2009, Andrey Borzenkov wrote:
> fbcon: avoid circular locking dependency between fb_info->lock and mm->mmap_sem
>
> In fbcon notifier the handler for FB_EVENT_SET_CONSOLE_MAP doesn't need
> to hold fb_info->lock.
>
> Simply unlock it before calling set_con2fb_map(), that could try to
> acquire mm->mmap_sem to avoid a circular locking dependency with
> fb_mmap() (that acquires mm->mmap_sem -> fb_info-lock).

However, set_con2fb_map() accesses the array of fb_info pointers
registered_fb[], which seems to be a bit unsafe now the BKL is no longer held.

> Reported-by: Andrey Borzenkov <arvidjaar@xxxxxxx>
> Signed-off-by: Andrea Righi <righi.andrea@xxxxxxxxx>
> ---
> drivers/video/console/fbcon.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> index 1657b96..81fc2f7 100644
> --- a/drivers/video/console/fbcon.c
> +++ b/drivers/video/console/fbcon.c
> @@ -3169,9 +3169,15 @@ static int fbcon_event_notify(struct notifier_block *self,
> ret = fbcon_fb_unregistered(info);
> break;
> case FB_EVENT_SET_CONSOLE_MAP:
> + /*
> + * XXX: info is not used here, we can unlock it to avoid
> + * circular locking with &current->mm->mmap_sem in fb_mmap().
> + */
> + unlock_fb_info(info);
> con2fb = event->data;
> ret = set_con2fb_map(con2fb->console - 1,
> con2fb->framebuffer, 1);
> + lock_fb_info(info);
> break;
> case FB_EVENT_GET_CONSOLE_MAP:
> con2fb = event->data;
>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/