net/net_namespace: Check the return value of register_pernet_subsys()
diff mbox series

Message ID 20181224014239.11601-1-pakki001@umn.edu
State In Next
Commit 0eb987c874dc93f9c9d85a6465dbde20fdd3884c
Headers show
Series
  • net/net_namespace: Check the return value of register_pernet_subsys()
Related show

Commit Message

Aditya Pakki Dec. 24, 2018, 1:42 a.m. UTC
In net_ns_init(), register_pernet_subsys() could fail while registering
network namespace subsystems. The fix checks the return value and
sends a panic() on failure.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 net/core/net_namespace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kirill Tkhai Dec. 24, 2018, 9:35 a.m. UTC | #1
On 24.12.2018 04:42, Aditya Pakki wrote:
> In net_ns_init(), register_pernet_subsys() could fail while registering
> network namespace subsystems. The fix checks the return value and
> sends a panic() on failure.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>

> ---
>  net/core/net_namespace.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
> index fefe72774aeb..af8849a7a9c3 100644
> --- a/net/core/net_namespace.c
> +++ b/net/core/net_namespace.c
> @@ -917,7 +917,8 @@ static int __init net_ns_init(void)
>  	init_net_initialized = true;
>  	up_write(&pernet_ops_rwsem);
>  
> -	register_pernet_subsys(&net_ns_ops);
> +	if (register_pernet_subsys(&net_ns_ops))
> +		panic("Could not register network namespace subsystems");
>  
>  	rtnl_register(PF_UNSPEC, RTM_NEWNSID, rtnl_net_newid, NULL,
>  		      RTNL_FLAG_DOIT_UNLOCKED);
>
David Miller Dec. 24, 2018, 10:46 p.m. UTC | #2
From: Aditya Pakki <pakki001@umn.edu>
Date: Sun, 23 Dec 2018 19:42:38 -0600

> In net_ns_init(), register_pernet_subsys() could fail while registering
> network namespace subsystems. The fix checks the return value and
> sends a panic() on failure.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

Applied.

Patch
diff mbox series

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index fefe72774aeb..af8849a7a9c3 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -917,7 +917,8 @@  static int __init net_ns_init(void)
 	init_net_initialized = true;
 	up_write(&pernet_ops_rwsem);
 
-	register_pernet_subsys(&net_ns_ops);
+	if (register_pernet_subsys(&net_ns_ops))
+		panic("Could not register network namespace subsystems");
 
 	rtnl_register(PF_UNSPEC, RTM_NEWNSID, rtnl_net_newid, NULL,
 		      RTNL_FLAG_DOIT_UNLOCKED);