public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Imre Deak <imre.deak@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.cz>,
	Peter Hurley <peter@hurleysoftware.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] vt: fix locking around vt_bind/vt_unbind
Date: Tue, 16 Dec 2014 08:37:58 +0100	[thread overview]
Message-ID: <20141216073758.GH2711@phenom.ffwll.local> (raw)
In-Reply-To: <1418681761-3709-2-git-send-email-imre.deak@intel.com>

On Tue, Dec 16, 2014 at 12:16:00AM +0200, Imre Deak wrote:
> Currently vt_bind and vt_unbind access at least the con_driver object
> and registered_con_driver array without holding the console lock. Fix
> this by locking around the whole function in each case.
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> Reviewed-by: Peter Hurley <peter@hurleysoftware.com>

Well it's not pretty that console_lock is constantly growing and getting
pushed up the lock dep chain the past few years for various reasons, but
this here looks genuine and won't wrap new locks in console_lock.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/tty/vt/vt.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 9c046fb..5d36c23 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -3318,11 +3318,8 @@ static int vt_bind(struct con_driver *con)
>  		if (first == 0 && last == MAX_NR_CONSOLES -1)
>  			deflt = 1;
>  
> -		if (first != -1) {
> -			console_lock();
> +		if (first != -1)
>  			do_bind_con_driver(csw, first, last, deflt);
> -			console_unlock();
> -		}
>  
>  		first = -1;
>  		last = -1;
> @@ -3362,9 +3359,7 @@ static int vt_unbind(struct con_driver *con)
>  			deflt = 1;
>  
>  		if (first != -1) {
> -			console_lock();
>  			ret = do_unbind_con_driver(csw, first, last, deflt);
> -			console_unlock();
>  			if (ret != 0)
>  				return ret;
>  		}
> @@ -3394,11 +3389,15 @@ static ssize_t store_bind(struct device *dev, struct device_attribute *attr,
>  	struct con_driver *con = dev_get_drvdata(dev);
>  	int bind = simple_strtoul(buf, NULL, 0);
>  
> +	console_lock();
> +
>  	if (bind)
>  		vt_bind(con);
>  	else
>  		vt_unbind(con);
>  
> +	console_unlock();
> +
>  	return count;
>  }
>  
> -- 
> 1.8.4
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

  reply	other threads:[~2014-12-16  7:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 22:15 [PATCH v4 1/3] vt: fix check for system/busy console drivers when unregistering them Imre Deak
2014-12-15 22:16 ` [PATCH v4 2/3] vt: fix locking around vt_bind/vt_unbind Imre Deak
2014-12-16  7:37   ` Daniel Vetter [this message]
2014-12-15 22:16 ` [PATCH v4 3/3] vt: fix console lock vs. kernfs s_active lock order Imre Deak
2014-12-16  7:53   ` Daniel Vetter
2014-12-16 10:23     ` Imre Deak
2014-12-16 12:50       ` Peter Hurley
2014-12-16 13:45         ` Daniel Vetter
2014-12-16 14:38         ` Imre Deak
2014-12-16 15:00           ` Peter Hurley
2014-12-16 15:10             ` Daniel Vetter
2014-12-16 15:48               ` Peter Hurley
2014-12-16 16:22             ` Imre Deak
2014-12-16 17:15               ` Peter Hurley
2014-12-16 17:42                 ` Daniel Vetter
2015-03-26 19:59                   ` Jesse Barnes
2015-03-26 21:01                     ` Greg Kroah-Hartman
2015-03-26 21:05                       ` Imre Deak
2015-03-27  7:46                         ` Daniel Vetter
2015-03-31 15:59                           ` Greg Kroah-Hartman
2015-04-01 18:06                             ` [PATCH] " Imre Deak
2014-12-16  7:35 ` [PATCH v4 1/3] vt: fix check for system/busy console drivers when unregistering them Daniel Vetter

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=20141216073758.GH2711@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=gregkh@linuxfoundation.org \
    --cc=imre.deak@intel.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    /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