linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vsock: Make transport the proto owner
@ 2014-05-01 22:20 Andy King
  2014-05-05 17:14 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Andy King @ 2014-05-01 22:20 UTC (permalink / raw)
  To: netdev, linux-kernel, virtualization
  Cc: gregkh, davem, pv-drivers, Andy King, stable

Right now the core vsock module is the owner of the proto family. This
means there's nothing preventing the transport module from unloading if
there are open sockets, which results in a panic. Fix that by allowing
the transport to be the owner, which will refcount it properly.

Includes version bump to 1.0.1.0-k

Passes checkpatch this time, I swear...

Cc: stable@vger.kernel.org
Acked-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: Andy King <acking@vmware.com>
---
 include/net/af_vsock.h   |    6 ++++-
 net/vmw_vsock/af_vsock.c |   47 +++++++++++++++++++++------------------------
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 7d64d36..4282778 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -155,7 +155,11 @@ struct vsock_transport {
 
 /**** CORE ****/
 
-int vsock_core_init(const struct vsock_transport *t);
+int __vsock_core_init(const struct vsock_transport *t, struct module *owner);
+static inline int vsock_core_init(const struct vsock_transport *t)
+{
+	return __vsock_core_init(t, THIS_MODULE);
+}
 void vsock_core_exit(void);
 
 /**** UTILS ****/
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 5adfd94..85d232b 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1925,9 +1925,23 @@ static struct miscdevice vsock_device = {
 	.fops		= &vsock_device_ops,
 };
 
-static int __vsock_core_init(void)
+int __vsock_core_init(const struct vsock_transport *t, struct module *owner)
 {
-	int err;
+	int err = mutex_lock_interruptible(&vsock_register_mutex);
+
+	if (err)
+		return err;
+
+	if (transport) {
+		err = -EBUSY;
+		goto err_busy;
+	}
+
+	/* Transport must be the owner of the protocol so that it can't
+	 * unload while there are open sockets.
+	 */
+	vsock_proto.owner = owner;
+	transport = t;
 
 	vsock_init_tables();
 
@@ -1951,36 +1965,19 @@ static int __vsock_core_init(void)
 		goto err_unregister_proto;
 	}
 
+	mutex_unlock(&vsock_register_mutex);
 	return 0;
 
 err_unregister_proto:
 	proto_unregister(&vsock_proto);
 err_misc_deregister:
 	misc_deregister(&vsock_device);
-	return err;
-}
-
-int vsock_core_init(const struct vsock_transport *t)
-{
-	int retval = mutex_lock_interruptible(&vsock_register_mutex);
-	if (retval)
-		return retval;
-
-	if (transport) {
-		retval = -EBUSY;
-		goto out;
-	}
-
-	transport = t;
-	retval = __vsock_core_init();
-	if (retval)
-		transport = NULL;
-
-out:
+	transport = NULL;
+err_busy:
 	mutex_unlock(&vsock_register_mutex);
-	return retval;
+	return err;
 }
-EXPORT_SYMBOL_GPL(vsock_core_init);
+EXPORT_SYMBOL_GPL(__vsock_core_init);
 
 void vsock_core_exit(void)
 {
@@ -2000,5 +1997,5 @@ EXPORT_SYMBOL_GPL(vsock_core_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Socket Family");
-MODULE_VERSION("1.0.0.0-k");
+MODULE_VERSION("1.0.1.0-k");
 MODULE_LICENSE("GPL v2");
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] vsock: Make transport the proto owner
  2014-05-01 22:20 [PATCH] vsock: Make transport the proto owner Andy King
@ 2014-05-05 17:14 ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-05-05 17:14 UTC (permalink / raw)
  To: acking; +Cc: netdev, linux-kernel, virtualization, gregkh, pv-drivers, stable

From: Andy King <acking@vmware.com>
Date: Thu,  1 May 2014 15:20:43 -0700

> Right now the core vsock module is the owner of the proto family. This
> means there's nothing preventing the transport module from unloading if
> there are open sockets, which results in a panic. Fix that by allowing
> the transport to be the owner, which will refcount it properly.
> 
> Includes version bump to 1.0.1.0-k
> 
> Passes checkpatch this time, I swear...
> 
> Cc: stable@vger.kernel.org

Please do not explicitly CC: stable for networking submissions, instead please
just ask me to queue it up for -stable submission since I handle networking
-stable myself.

> Acked-by: Dmitry Torokhov <dtor@vmware.com>
> Signed-off-by: Andy King <acking@vmware.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vsock: Make transport the proto owner
  2014-05-01 22:09 Andy King
@ 2014-05-01 22:10 ` Andy King
  0 siblings, 0 replies; 4+ messages in thread
From: Andy King @ 2014-05-01 22:10 UTC (permalink / raw)
  To: netdev, linux-kernel, virtualization; +Cc: gregkh, davem, pv-drivers, stable

Oh just shoot me now, doesn't even pass checkpatch *hangs head in shame*
Dave/Greg, flame away if you like...

- Andy

----- Original Message -----
> Right now the core vsock module is the owner of the proto family. This
> means there's nothing preventing the transport module from unloading if
> there are open sockets, which results in a panic. Fix that by allowing
> the transport to be the owner, which will refcount it properly.
> 
> Includes version bump to 1.0.1.0-k
> 
> Cc: stable@vger.kernel.org
> Acked-by: Dmitry Torokhov <dtor@vmware.com>
> Signed-off-by: Andy King <acking@vmware.com>
> ---
>  include/net/af_vsock.h   |    6 +++++-
>  net/vmw_vsock/af_vsock.c |   46
>  +++++++++++++++++++++-------------------------
>  2 files changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
> index 7d64d36..8f02e5c 100644
> --- a/include/net/af_vsock.h
> +++ b/include/net/af_vsock.h
> @@ -155,7 +155,11 @@ struct vsock_transport {
>  
>  /**** CORE ****/
>  
> -int vsock_core_init(const struct vsock_transport *t);
> +int __vsock_core_init(const struct vsock_transport *t, struct module
> *owner);
> +static inline int vsock_core_init(const struct vsock_transport *t)
> +{
> +   return __vsock_core_init(t, THIS_MODULE);
> +}
>  void vsock_core_exit(void);
>  
>  /**** UTILS ****/
> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> index 5adfd94..5743553 100644
> --- a/net/vmw_vsock/af_vsock.c
> +++ b/net/vmw_vsock/af_vsock.c
> @@ -1925,9 +1925,22 @@ static struct miscdevice vsock_device = {
>  	.fops		= &vsock_device_ops,
>  };
>  
> -static int __vsock_core_init(void)
> +int __vsock_core_init(const struct vsock_transport *t, struct module *owner)
>  {
> -	int err;
> +	int err = mutex_lock_interruptible(&vsock_register_mutex);
> +	if (err)
> +		return err;
> +
> +	if (transport) {
> +		err = -EBUSY;
> +		goto err_busy;
> +	}
> +
> +	/* Transport must be the owner of the protocol so that it can't
> +	 * unload while there are open sockets.
> +	 */
> +	vsock_proto.owner = owner;
> +	transport = t;
>  
>  	vsock_init_tables();
>  
> @@ -1951,36 +1964,19 @@ static int __vsock_core_init(void)
>  		goto err_unregister_proto;
>  	}
>  
> +	mutex_unlock(&vsock_register_mutex);
>  	return 0;
>  
>  err_unregister_proto:
>  	proto_unregister(&vsock_proto);
>  err_misc_deregister:
>  	misc_deregister(&vsock_device);
> -	return err;
> -}
> -
> -int vsock_core_init(const struct vsock_transport *t)
> -{
> -	int retval = mutex_lock_interruptible(&vsock_register_mutex);
> -	if (retval)
> -		return retval;
> -
> -	if (transport) {
> -		retval = -EBUSY;
> -		goto out;
> -	}
> -
> -	transport = t;
> -	retval = __vsock_core_init();
> -	if (retval)
> -		transport = NULL;
> -
> -out:
> +	transport = NULL;
> +err_busy:
>  	mutex_unlock(&vsock_register_mutex);
> -	return retval;
> +	return err;
>  }
> -EXPORT_SYMBOL_GPL(vsock_core_init);
> +EXPORT_SYMBOL_GPL(__vsock_core_init);
>  
>  void vsock_core_exit(void)
>  {
> @@ -2000,5 +1996,5 @@ EXPORT_SYMBOL_GPL(vsock_core_exit);
>  
>  MODULE_AUTHOR("VMware, Inc.");
>  MODULE_DESCRIPTION("VMware Virtual Socket Family");
> -MODULE_VERSION("1.0.0.0-k");
> +MODULE_VERSION("1.0.1.0-k");
>  MODULE_LICENSE("GPL v2");
> --
> 1.7.4.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] vsock: Make transport the proto owner
@ 2014-05-01 22:09 Andy King
  2014-05-01 22:10 ` Andy King
  0 siblings, 1 reply; 4+ messages in thread
From: Andy King @ 2014-05-01 22:09 UTC (permalink / raw)
  To: netdev, linux-kernel, virtualization
  Cc: gregkh, davem, pv-drivers, Andy King, stable

Right now the core vsock module is the owner of the proto family. This
means there's nothing preventing the transport module from unloading if
there are open sockets, which results in a panic. Fix that by allowing
the transport to be the owner, which will refcount it properly.

Includes version bump to 1.0.1.0-k

Cc: stable@vger.kernel.org
Acked-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: Andy King <acking@vmware.com>
---
 include/net/af_vsock.h   |    6 +++++-
 net/vmw_vsock/af_vsock.c |   46 +++++++++++++++++++++-------------------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 7d64d36..8f02e5c 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -155,7 +155,11 @@ struct vsock_transport {
 
 /**** CORE ****/
 
-int vsock_core_init(const struct vsock_transport *t);
+int __vsock_core_init(const struct vsock_transport *t, struct module *owner);
+static inline int vsock_core_init(const struct vsock_transport *t)
+{
+   return __vsock_core_init(t, THIS_MODULE);
+}
 void vsock_core_exit(void);
 
 /**** UTILS ****/
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 5adfd94..5743553 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1925,9 +1925,22 @@ static struct miscdevice vsock_device = {
 	.fops		= &vsock_device_ops,
 };
 
-static int __vsock_core_init(void)
+int __vsock_core_init(const struct vsock_transport *t, struct module *owner)
 {
-	int err;
+	int err = mutex_lock_interruptible(&vsock_register_mutex);
+	if (err)
+		return err;
+
+	if (transport) {
+		err = -EBUSY;
+		goto err_busy;
+	}
+
+	/* Transport must be the owner of the protocol so that it can't
+	 * unload while there are open sockets.
+	 */
+	vsock_proto.owner = owner;
+	transport = t;
 
 	vsock_init_tables();
 
@@ -1951,36 +1964,19 @@ static int __vsock_core_init(void)
 		goto err_unregister_proto;
 	}
 
+	mutex_unlock(&vsock_register_mutex);
 	return 0;
 
 err_unregister_proto:
 	proto_unregister(&vsock_proto);
 err_misc_deregister:
 	misc_deregister(&vsock_device);
-	return err;
-}
-
-int vsock_core_init(const struct vsock_transport *t)
-{
-	int retval = mutex_lock_interruptible(&vsock_register_mutex);
-	if (retval)
-		return retval;
-
-	if (transport) {
-		retval = -EBUSY;
-		goto out;
-	}
-
-	transport = t;
-	retval = __vsock_core_init();
-	if (retval)
-		transport = NULL;
-
-out:
+	transport = NULL;
+err_busy:
 	mutex_unlock(&vsock_register_mutex);
-	return retval;
+	return err;
 }
-EXPORT_SYMBOL_GPL(vsock_core_init);
+EXPORT_SYMBOL_GPL(__vsock_core_init);
 
 void vsock_core_exit(void)
 {
@@ -2000,5 +1996,5 @@ EXPORT_SYMBOL_GPL(vsock_core_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Socket Family");
-MODULE_VERSION("1.0.0.0-k");
+MODULE_VERSION("1.0.1.0-k");
 MODULE_LICENSE("GPL v2");
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-05 17:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-01 22:20 [PATCH] vsock: Make transport the proto owner Andy King
2014-05-05 17:14 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-05-01 22:09 Andy King
2014-05-01 22:10 ` Andy King

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).