hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/drivers/net/wireguard/socket.c
....@@ -49,7 +49,7 @@
4949 rt = dst_cache_get_ip4(cache, &fl.saddr);
5050
5151 if (!rt) {
52
- security_sk_classify_flow(sock, flowi4_to_flowi(&fl));
52
+ security_sk_classify_flow(sock, flowi4_to_flowi_common(&fl));
5353 if (unlikely(!inet_confirm_addr(sock_net(sock), NULL, 0,
5454 fl.saddr, RT_SCOPE_HOST))) {
5555 endpoint->src4.s_addr = 0;
....@@ -129,7 +129,7 @@
129129 dst = dst_cache_get_ip6(cache, &fl.saddr);
130130
131131 if (!dst) {
132
- security_sk_classify_flow(sock, flowi6_to_flowi(&fl));
132
+ security_sk_classify_flow(sock, flowi6_to_flowi_common(&fl));
133133 if (unlikely(!ipv6_addr_any(&fl.saddr) &&
134134 !ipv6_chk_addr(sock_net(sock), &fl.saddr, NULL, 0))) {
135135 endpoint->src6 = fl.saddr = in6addr_any;
....@@ -160,6 +160,7 @@
160160 rcu_read_unlock_bh();
161161 return ret;
162162 #else
163
+ kfree_skb(skb);
163164 return -EAFNOSUPPORT;
164165 #endif
165166 }
....@@ -241,7 +242,7 @@
241242 endpoint->addr4.sin_addr.s_addr = ip_hdr(skb)->saddr;
242243 endpoint->src4.s_addr = ip_hdr(skb)->daddr;
243244 endpoint->src_if4 = skb->skb_iif;
244
- } else if (skb->protocol == htons(ETH_P_IPV6)) {
245
+ } else if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6)) {
245246 endpoint->addr6.sin6_family = AF_INET6;
246247 endpoint->addr6.sin6_port = udp_hdr(skb)->source;
247248 endpoint->addr6.sin6_addr = ipv6_hdr(skb)->saddr;
....@@ -284,7 +285,7 @@
284285 peer->endpoint.addr4 = endpoint->addr4;
285286 peer->endpoint.src4 = endpoint->src4;
286287 peer->endpoint.src_if4 = endpoint->src_if4;
287
- } else if (endpoint->addr.sa_family == AF_INET6) {
288
+ } else if (IS_ENABLED(CONFIG_IPV6) && endpoint->addr.sa_family == AF_INET6) {
288289 peer->endpoint.addr6 = endpoint->addr6;
289290 peer->endpoint.src6 = endpoint->src6;
290291 } else {
....@@ -308,7 +309,7 @@
308309 {
309310 write_lock_bh(&peer->endpoint_lock);
310311 memset(&peer->endpoint.src6, 0, sizeof(peer->endpoint.src6));
311
- dst_cache_reset(&peer->endpoint_cache);
312
+ dst_cache_reset_now(&peer->endpoint_cache);
312313 write_unlock_bh(&peer->endpoint_lock);
313314 }
314315
....@@ -430,7 +431,7 @@
430431 if (new4)
431432 wg->incoming_port = ntohs(inet_sk(new4)->inet_sport);
432433 mutex_unlock(&wg->socket_update_lock);
433
- synchronize_rcu();
434
+ synchronize_net();
434435 sock_free(old4);
435436 sock_free(old6);
436437 }