udp: must lock the socket in udp_disconnect()
Baozeng Ding reported KASAN traces showing uses after free in
udp_lib_get_port() and other related UDP functions.
A CONFIG_DEBUG_PAGEALLOC=y kernel would eventually crash.
I could write a reproducer with two threads doing :
static int sock_fd;
static void *thr1(void *arg)
{
for (;;) {
connect(sock_fd, (const struct sockaddr *)arg,
sizeof(struct sockaddr_in));
}
}
static void *thr2(void *arg)
{
struct sockaddr_in unspec;
for (;;) {
memset(&unspec, 0, sizeof(unspec));
connect(sock_fd, (const struct sockaddr *)&unspec,
sizeof(unspec));
}
}
Problem is that udp_disconnect() could run without holding socket lock,
and this was causing list corruptions.
Signed-off-by:
Eric Dumazet <edumazet@google.com>
Reported-by:
Baozeng Ding <sploving1@gmail.com>
Signed-off-by:
David S. Miller <davem@davemloft.net>
Showing
- include/net/udp.h 1 addition, 0 deletionsinclude/net/udp.h
- net/ipv4/ping.c 1 addition, 1 deletionnet/ipv4/ping.c
- net/ipv4/raw.c 1 addition, 1 deletionnet/ipv4/raw.c
- net/ipv4/udp.c 11 additions, 2 deletionsnet/ipv4/udp.c
- net/ipv6/ping.c 1 addition, 1 deletionnet/ipv6/ping.c
- net/ipv6/raw.c 1 addition, 1 deletionnet/ipv6/raw.c
- net/l2tp/l2tp_ip.c 1 addition, 1 deletionnet/l2tp/l2tp_ip.c
- net/l2tp/l2tp_ip6.c 1 addition, 1 deletionnet/l2tp/l2tp_ip6.c
Loading
Please register or sign in to comment