mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
Revert "udp: annotate data-races around udp->encap_type"
This reverts commit 158b71f3a9 which is
commit 70a36f571362a8de8b8c02d21ae524fc776287f2 upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.
Bug: 161946584
Change-Id: I516d935c83a8731f077b5b4e72e762c8a9a63bd1
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -629,7 +629,7 @@ static void __gtp_encap_destroy(struct sock *sk)
|
|||||||
gtp->sk0 = NULL;
|
gtp->sk0 = NULL;
|
||||||
else
|
else
|
||||||
gtp->sk1u = NULL;
|
gtp->sk1u = NULL;
|
||||||
WRITE_ONCE(udp_sk(sk)->encap_type, 0);
|
udp_sk(sk)->encap_type = 0;
|
||||||
rcu_assign_sk_user_data(sk, NULL);
|
rcu_assign_sk_user_data(sk, NULL);
|
||||||
release_sock(sk);
|
release_sock(sk);
|
||||||
sock_put(sk);
|
sock_put(sk);
|
||||||
@@ -681,7 +681,7 @@ static int gtp_encap_recv(struct sock *sk, struct sk_buff *skb)
|
|||||||
|
|
||||||
netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk);
|
netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk);
|
||||||
|
|
||||||
switch (READ_ONCE(udp_sk(sk)->encap_type)) {
|
switch (udp_sk(sk)->encap_type) {
|
||||||
case UDP_ENCAP_GTP0:
|
case UDP_ENCAP_GTP0:
|
||||||
netdev_dbg(gtp->dev, "received GTP0 packet\n");
|
netdev_dbg(gtp->dev, "received GTP0 packet\n");
|
||||||
ret = gtp0_udp_encap_recv(gtp, skb);
|
ret = gtp0_udp_encap_recv(gtp, skb);
|
||||||
|
|||||||
@@ -733,7 +733,7 @@ int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
|
|||||||
iph->saddr, uh->source, skb->dev->ifindex,
|
iph->saddr, uh->source, skb->dev->ifindex,
|
||||||
inet_sdif(skb), udptable, NULL);
|
inet_sdif(skb), udptable, NULL);
|
||||||
|
|
||||||
if (!sk || READ_ONCE(udp_sk(sk)->encap_type)) {
|
if (!sk || udp_sk(sk)->encap_type) {
|
||||||
/* No socket for error: try tunnels before discarding */
|
/* No socket for error: try tunnels before discarding */
|
||||||
if (static_branch_unlikely(&udp_encap_needed_key)) {
|
if (static_branch_unlikely(&udp_encap_needed_key)) {
|
||||||
sk = __udp4_lib_err_encap(net, iph, uh, udptable, sk, skb,
|
sk = __udp4_lib_err_encap(net, iph, uh, udptable, sk, skb,
|
||||||
@@ -2114,8 +2114,7 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
nf_reset_ct(skb);
|
nf_reset_ct(skb);
|
||||||
|
|
||||||
if (static_branch_unlikely(&udp_encap_needed_key) &&
|
if (static_branch_unlikely(&udp_encap_needed_key) && up->encap_type) {
|
||||||
READ_ONCE(up->encap_type)) {
|
|
||||||
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
|
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2700,7 +2699,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
|
|||||||
#endif
|
#endif
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case UDP_ENCAP_L2TPINUDP:
|
case UDP_ENCAP_L2TPINUDP:
|
||||||
WRITE_ONCE(up->encap_type, val);
|
up->encap_type = val;
|
||||||
udp_tunnel_encap_enable(sk);
|
udp_tunnel_encap_enable(sk);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2801,7 +2800,7 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case UDP_ENCAP:
|
case UDP_ENCAP:
|
||||||
val = READ_ONCE(up->encap_type);
|
val = up->encap_type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UDP_NO_CHECK6_TX:
|
case UDP_NO_CHECK6_TX:
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
|
|||||||
struct udphdr *uh;
|
struct udphdr *uh;
|
||||||
struct iphdr *iph;
|
struct iphdr *iph;
|
||||||
int iphlen, len;
|
int iphlen, len;
|
||||||
|
|
||||||
__u8 *udpdata;
|
__u8 *udpdata;
|
||||||
__be32 *udpdata32;
|
__be32 *udpdata32;
|
||||||
u16 encap_type;
|
__u16 encap_type = up->encap_type;
|
||||||
|
|
||||||
encap_type = READ_ONCE(up->encap_type);
|
|
||||||
/* if this is not encapsulated socket, then just return now */
|
/* if this is not encapsulated socket, then just return now */
|
||||||
if (!encap_type)
|
if (!encap_type)
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -598,7 +598,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||||||
sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
|
sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
|
||||||
inet6_iif(skb), inet6_sdif(skb), udptable, NULL);
|
inet6_iif(skb), inet6_sdif(skb), udptable, NULL);
|
||||||
|
|
||||||
if (!sk || READ_ONCE(udp_sk(sk)->encap_type)) {
|
if (!sk || udp_sk(sk)->encap_type) {
|
||||||
/* No socket for error: try tunnels before discarding */
|
/* No socket for error: try tunnels before discarding */
|
||||||
if (static_branch_unlikely(&udpv6_encap_needed_key)) {
|
if (static_branch_unlikely(&udpv6_encap_needed_key)) {
|
||||||
sk = __udp6_lib_err_encap(net, hdr, offset, uh,
|
sk = __udp6_lib_err_encap(net, hdr, offset, uh,
|
||||||
@@ -712,8 +712,7 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
nf_reset_ct(skb);
|
nf_reset_ct(skb);
|
||||||
|
|
||||||
if (static_branch_unlikely(&udpv6_encap_needed_key) &&
|
if (static_branch_unlikely(&udpv6_encap_needed_key) && up->encap_type) {
|
||||||
READ_ONCE(up->encap_type)) {
|
|
||||||
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
|
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -81,14 +81,14 @@ int xfrm6_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
|
|||||||
struct ipv6hdr *ip6h;
|
struct ipv6hdr *ip6h;
|
||||||
int len;
|
int len;
|
||||||
int ip6hlen = sizeof(struct ipv6hdr);
|
int ip6hlen = sizeof(struct ipv6hdr);
|
||||||
|
|
||||||
__u8 *udpdata;
|
__u8 *udpdata;
|
||||||
__be32 *udpdata32;
|
__be32 *udpdata32;
|
||||||
u16 encap_type;
|
__u16 encap_type = up->encap_type;
|
||||||
|
|
||||||
if (skb->protocol == htons(ETH_P_IP))
|
if (skb->protocol == htons(ETH_P_IP))
|
||||||
return xfrm4_udp_encap_rcv(sk, skb);
|
return xfrm4_udp_encap_rcv(sk, skb);
|
||||||
|
|
||||||
encap_type = READ_ONCE(up->encap_type);
|
|
||||||
/* if this is not encapsulated socket, then just return now */
|
/* if this is not encapsulated socket, then just return now */
|
||||||
if (!encap_type)
|
if (!encap_type)
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1139,9 +1139,9 @@ static void l2tp_tunnel_destruct(struct sock *sk)
|
|||||||
switch (tunnel->encap) {
|
switch (tunnel->encap) {
|
||||||
case L2TP_ENCAPTYPE_UDP:
|
case L2TP_ENCAPTYPE_UDP:
|
||||||
/* No longer an encapsulation socket. See net/ipv4/udp.c */
|
/* No longer an encapsulation socket. See net/ipv4/udp.c */
|
||||||
WRITE_ONCE(udp_sk(sk)->encap_type, 0);
|
(udp_sk(sk))->encap_type = 0;
|
||||||
udp_sk(sk)->encap_rcv = NULL;
|
(udp_sk(sk))->encap_rcv = NULL;
|
||||||
udp_sk(sk)->encap_destroy = NULL;
|
(udp_sk(sk))->encap_destroy = NULL;
|
||||||
break;
|
break;
|
||||||
case L2TP_ENCAPTYPE_IP:
|
case L2TP_ENCAPTYPE_IP:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user