Patch "xfrm: Fix ignored return value in xfrm6_init()" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    xfrm: Fix ignored return value in xfrm6_init()

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xfrm-fix-ignored-return-value-in-xfrm6_init.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 80516bc9faeabe08d9126032d89d8e0fedead220
Author: Chen Zhongjin <chenzhongjin@xxxxxxxxxx>
Date:   Thu Nov 3 17:07:13 2022 +0800

    xfrm: Fix ignored return value in xfrm6_init()
    
    [ Upstream commit 40781bfb836eda57d19c0baa37c7e72590e05fdc ]
    
    When IPv6 module initializing in xfrm6_init(), register_pernet_subsys()
    is possible to fail but its return value is ignored.
    
    If IPv6 initialization fails later and xfrm6_fini() is called,
    removing uninitialized list in xfrm6_net_ops will cause null-ptr-deref:
    
    KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
    CPU: 1 PID: 330 Comm: insmod
    RIP: 0010:unregister_pernet_operations+0xc9/0x450
    Call Trace:
     <TASK>
     unregister_pernet_subsys+0x31/0x3e
     xfrm6_fini+0x16/0x30 [ipv6]
     ip6_route_init+0xcd/0x128 [ipv6]
     inet6_init+0x29c/0x602 [ipv6]
     ...
    
    Fix it by catching the error return value of register_pernet_subsys().
    
    Fixes: 8d068875caca ("xfrm: make gc_thresh configurable in all namespaces")
    Signed-off-by: Chen Zhongjin <chenzhongjin@xxxxxxxxxx>
    Reviewed-by: Leon Romanovsky <leonro@xxxxxxxxxx>
    Signed-off-by: Steffen Klassert <steffen.klassert@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index b0d80cef7c2b..44d616d0bd00 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -412,9 +412,13 @@ int __init xfrm6_init(void)
 	if (ret)
 		goto out_state;
 
-	register_pernet_subsys(&xfrm6_net_ops);
+	ret = register_pernet_subsys(&xfrm6_net_ops);
+	if (ret)
+		goto out_protocol;
 out:
 	return ret;
+out_protocol:
+	xfrm6_protocol_fini();
 out_state:
 	xfrm6_state_fini();
 out_policy:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux