]> git.baikalelectronics.ru Git - kernel.git/commit
udp: fix dst races with multicast early demux
authorEric Dumazet <edumazet@google.com>
Sat, 1 Aug 2015 10:14:33 +0000 (12:14 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 4 Aug 2015 05:16:50 +0000 (22:16 -0700)
commit2e0359bf538fce63a2978a81805bffdb228b14a5
tree69bf946cc397f31aa7cbfc8d19c04b50d6f0fc76
parent04d5ca2ea91c15cfe8ab1c94acf14d3149aa203d
udp: fix dst races with multicast early demux

Multicast dst are not cached. They carry DST_NOCACHE.

As mentioned in commit 5df34d96e64e0d ("ipv4: fix dst race in
sk_dst_get()"), these dst need special care before caching them
into a socket.

Caching them is allowed only if their refcnt was not 0, ie we
must use atomic_inc_not_zero()

Also, we must use READ_ONCE() to fetch sk->sk_rx_dst, as mentioned
in commit b4551c06ae1f8 ("tcp: prevent fetching dst twice in early demux
code")

Fixes: f6730a094d56 ("udp: ipv4: Add udp early demux")
Tested-by: Gregory Hoggarth <Gregory.Hoggarth@alliedtelesis.co.nz>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Gregory Hoggarth <Gregory.Hoggarth@alliedtelesis.co.nz>
Reported-by: Alex Gartrell <agartrell@fb.com>
Cc: Michal Kubeček <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/udp.c