mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Righi <righi.andrea@gmail.com>
To: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Dave Jones <davej@redhat.com>,
	Johannes Weiner <hannes@saeurebad.de>,
	Harvey Harrison <harvey.harrison@gmail.com>,
	Stefan Richter <stefanr@s5r6.in-berlin.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fbmem: copy_from/to_user() with mutex held (v2)
Date: Tue, 20 Jan 2009 09:21:55 +0100	[thread overview]
Message-ID: <a2776ec50901200021y7583fa40h71d2ea56c89c44a6@mail.gmail.com> (raw)
In-Reply-To: <20090119215427.7f23a76f.krzysztof.h1@wp.pl>

On Mon, Jan 19, 2009 at 9:54 PM, Krzysztof Helt <krzysztof.h1@wp.pl> wrote:
> On Mon, 19 Jan 2009 12:04:04 +0100
> Andrea Righi <righi.andrea@gmail.com> wrote:
>
>> Avoid to call copy_from/to_user() with fb_info->lock mutex held in fbmem
>> ioctl().
>>
>> fb_mmap() is called under mm->mmap_sem (A) held, that also acquires
>> fb_info->lock (B); fb_ioctl() takes fb_info->lock (B) and does
>> copy_from/to_user() that might acquire mm->mmap_sem (A), causing a
>> deadlock.
>>
>> NOTE: it doesn't push down the fb_info->lock in each own driver's
>> fb_ioctl(), so there're still potential deadlocks somewhere.
>>
>
>> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
>> index 756efeb..fe6033e 100644
>> --- a/drivers/video/fbmem.c
>> +++ b/drivers/video/fbmem.c
>> @@ -1013,25 +1013,26 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
> (...)
>>       case FBIOPUT_VSCREENINFO:
>> -             if (copy_from_user(&var, argp, sizeof(var))) {
>> -                     ret =  -EFAULT;
>> -                     break;
>> -             }
>> +             if (copy_from_user(&var, argp, sizeof(var)))
>> +                     return -EFAULT;
>> +             if (!lock_fb_info(info))
>> +                     return -ENODEV;
>>               acquire_console_sem();
>>               info->flags |= FBINFO_MISC_USEREVENT;
>>               ret = fb_set_var(info, &var);
>> @@ -1041,104 +1042,109 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
>>                       ret = -EFAULT;
>>               break;
>
> I don't see a call to unlock_fb_info(info) in the case for FBIOPUT_VSCREENINFO.
> Is it intentional?

No, it's a bug :(. I'll post a new patch soon.

Thanks for reviewing!
-Andrea

>
> Kind regards,
> Krzysztof

      reply	other threads:[~2009-01-20  8:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-19 11:04 Andrea Righi
2009-01-19 20:54 ` Krzysztof Helt
2009-01-20  8:21   ` Andrea Righi [this message]

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=a2776ec50901200021y7583fa40h71d2ea56c89c44a6@mail.gmail.com \
    --to=righi.andrea@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=hannes@saeurebad.de \
    --cc=harvey.harrison@gmail.com \
    --cc=krzysztof.h1@wp.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefanr@s5r6.in-berlin.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®