ipv6_flowlabel_get() reads flowlabel_consistency and
flowlabel_state_ranges locklessly.
Use READ_ONCE() for these sysctl accesses.
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
v2:
- Shorten the commit message per review feedback
- Drop the Fixes and stable CC trailers
net/ipv6/ip6_flowlabel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index b1ccdf0dc646..1ab5ad0dcf24 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -620,7 +620,7 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq,
int err;
if (freq->flr_flags & IPV6_FL_F_REFLECT) {
- if (net->ipv6.sysctl.flowlabel_consistency) {
+ if (READ_ONCE(net->ipv6.sysctl.flowlabel_consistency)) {
net_info_ratelimited("Can not set IPV6_FL_F_REFLECT if flowlabel_consistency sysctl is enable\n");
return -EPERM;
}
@@ -633,7 +633,7 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq,
if (freq->flr_label & ~IPV6_FLOWLABEL_MASK)
return -EINVAL;
- if (net->ipv6.sysctl.flowlabel_state_ranges &&
+ if (READ_ONCE(net->ipv6.sysctl.flowlabel_state_ranges) &&
(freq->flr_label & IPV6_FLOWLABEL_STATELESS_FLAG))
return -ERANGE;
--
2.34.1