]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ipv6: use READ_ONCE() for bindv6only default in inet6_create()
authorRunyu Xiao <runyu.xiao@seu.edu.cn>
Tue, 2 Jun 2026 00:24:14 +0000 (08:24 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 5 Jun 2026 01:30:24 +0000 (18:30 -0700)
inet6_create() reads net->ipv6.sysctl.bindv6only locklessly.

Use READ_ONCE() for this sysctl access.

Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260602002414.1504106-1-runyu.xiao@seu.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/af_inet6.c

index 0a88b376141d70217d96976b7230fd4a34519d43..79fc6ce6ff77dfa5e565abd6a4f99a5591032955 100644 (file)
@@ -211,7 +211,7 @@ lookup_protocol:
        np->pmtudisc    = IPV6_PMTUDISC_WANT;
        inet6_assign_bit(REPFLOW, sk, READ_ONCE(net->ipv6.sysctl.flowlabel_reflect) &
                                      FLOWLABEL_REFLECT_ESTABLISHED);
-       sk->sk_ipv6only = net->ipv6.sysctl.bindv6only;
+       sk->sk_ipv6only = READ_ONCE(net->ipv6.sysctl.bindv6only);
        sk->sk_txrehash = READ_ONCE(net->core.sysctl_txrehash);
 
        /* Init the ipv4 part of the socket since we can have sockets