From: Krzysztof Helt <krzysztof.h1@wp.pl>
To: Andrea Righi <righi.andrea@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Dave Jones <davej@redhat.com>,
Johannes Weiner <hannes@saeurebad.de>,
Krzysztof Helt <krzysztof.h1@wp.pl>,
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: Mon, 19 Jan 2009 21:54:27 +0100 [thread overview]
Message-ID: <20090119215427.7f23a76f.krzysztof.h1@wp.pl> (raw)
In-Reply-To: <1232363044-8878-1-git-send-email-righi.andrea@gmail.com>
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?
Kind regards,
Krzysztof
next prev parent reply other threads:[~2009-01-19 20:51 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 [this message]
2009-01-20 8:21 ` Andrea Righi
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=20090119215427.7f23a76f.krzysztof.h1@wp.pl \
--to=krzysztof.h1@wp.pl \
--cc=akpm@linux-foundation.org \
--cc=davej@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hannes@saeurebad.de \
--cc=harvey.harrison@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=righi.andrea@gmail.com \
--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®