Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from David Miller:

 1) Unbalanced locking in mwifiex_process_country_ie, from Brian Norris.

 2) Fix thermal zone registration in iwlwifi, from Andrei
    Otcheretianski.

 3) Fix double free_irq in sgi ioc3 eth, from Thomas Bogendoerfer.

 4) Use after free in mptcp, from Florian Westphal.

 5) Use after free in wireguard's root_remove_peer_lists, from Eric
    Dumazet.

 6) Properly access packets heads in bonding alb code, from Eric
    Dumazet.

 7) Fix data race in skb_queue_len(), from Qian Cai.

 8) Fix regression in r8169 on some chips, from Heiner Kallweit.

 9) Fix XDP program ref counting in hv_netvsc, from Haiyang Zhang.

10) Certain kinds of set link netlink operations can cause a NULL deref
    in the ipv6 addrconf code. Fix from Eric Dumazet.

11) Don't cancel uninitialized work queue in drop monitor, from Ido
    Schimmel.

* git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (84 commits)
  net: thunderx: use proper interface type for RGMII
  mt76: mt7615: fix max_nss in mt7615_eeprom_parse_hw_cap
  bpf: Improve bucket_log calculation logic
  selftests/bpf: Test freeing sockmap/sockhash with a socket in it
  bpf, sockhash: Synchronize_rcu before free'ing map
  bpf, sockmap: Don't sleep while holding RCU lock on tear-down
  bpftool: Don't crash on missing xlated program instructions
  bpf, sockmap: Check update requirements after locking
  drop_monitor: Do not cancel uninitialized work item
  mlxsw: spectrum_dpipe: Add missing error path
  mlxsw: core: Add validation of hardware device types for MGPIR register
  mlxsw: spectrum_router: Clear offload indication from IPv6 nexthops on abort
  selftests: mlxsw: Add test cases for local table route replacement
  mlxsw: spectrum_router: Prevent incorrect replacement of local table routes
  net: dsa: microchip: enable module autoprobe
  ipv6/addrconf: fix potential NULL deref in inet6_set_link_af()
  dpaa_eth: support all modes with rate adapting PHYs
  net: stmmac: update pci platform data to use phy_interface
  net: stmmac: xgmac: fix missing IFF_MULTICAST checki in dwxgmac2_set_filter
  net: stmmac: fix missing IFF_MULTICAST check in dwmac4_set_filter
  ...
This commit is contained in:
Linus Torvalds
2020-02-08 17:15:08 -08:00
80 changed files with 783 additions and 328 deletions

View File

@@ -0,0 +1,74 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2020 Cloudflare
#include "test_progs.h"
static int connected_socket_v4(void)
{
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_port = htons(80),
.sin_addr = { inet_addr("127.0.0.1") },
};
socklen_t len = sizeof(addr);
int s, repair, err;
s = socket(AF_INET, SOCK_STREAM, 0);
if (CHECK_FAIL(s == -1))
goto error;
repair = TCP_REPAIR_ON;
err = setsockopt(s, SOL_TCP, TCP_REPAIR, &repair, sizeof(repair));
if (CHECK_FAIL(err))
goto error;
err = connect(s, (struct sockaddr *)&addr, len);
if (CHECK_FAIL(err))
goto error;
repair = TCP_REPAIR_OFF_NO_WP;
err = setsockopt(s, SOL_TCP, TCP_REPAIR, &repair, sizeof(repair));
if (CHECK_FAIL(err))
goto error;
return s;
error:
perror(__func__);
close(s);
return -1;
}
/* Create a map, populate it with one socket, and free the map. */
static void test_sockmap_create_update_free(enum bpf_map_type map_type)
{
const int zero = 0;
int s, map, err;
s = connected_socket_v4();
if (CHECK_FAIL(s == -1))
return;
map = bpf_create_map(map_type, sizeof(int), sizeof(int), 1, 0);
if (CHECK_FAIL(map == -1)) {
perror("bpf_create_map");
goto out;
}
err = bpf_map_update_elem(map, &zero, &s, BPF_NOEXIST);
if (CHECK_FAIL(err)) {
perror("bpf_map_update");
goto out;
}
out:
close(map);
close(s);
}
void test_sockmap_basic(void)
{
if (test__start_subtest("sockmap create_update_free"))
test_sockmap_create_update_free(BPF_MAP_TYPE_SOCKMAP);
if (test__start_subtest("sockhash create_update_free"))
test_sockmap_create_update_free(BPF_MAP_TYPE_SOCKHASH);
}

View File

@@ -46,7 +46,7 @@ void test_trampoline_count(void)
const char *fentry_name = "fentry/__set_task_comm";
const char *fexit_name = "fexit/__set_task_comm";
const char *object = "test_trampoline_count.o";
struct inst inst[MAX_TRAMP_PROGS] = { 0 };
struct inst inst[MAX_TRAMP_PROGS] = {};
int err, i = 0, duration = 0;
struct bpf_object *obj;
struct bpf_link *link;

View File

@@ -14,6 +14,7 @@ ALL_TESTS="
ipv4_plen
ipv4_replay
ipv4_flush
ipv4_local_replace
ipv6_add
ipv6_metric
ipv6_append_single
@@ -26,6 +27,7 @@ ALL_TESTS="
ipv6_delete_multipath
ipv6_replay_single
ipv6_replay_multipath
ipv6_local_replace
"
NUM_NETIFS=0
source $lib_dir/lib.sh
@@ -89,6 +91,43 @@ ipv4_flush()
fib_ipv4_flush_test "testns1"
}
ipv4_local_replace()
{
local ns="testns1"
RET=0
ip -n $ns link add name dummy1 type dummy
ip -n $ns link set dev dummy1 up
ip -n $ns route add table local 192.0.2.1/32 dev dummy1
fib4_trap_check $ns "table local 192.0.2.1/32 dev dummy1" false
check_err $? "Local table route not in hardware when should"
ip -n $ns route add table main 192.0.2.1/32 dev dummy1
fib4_trap_check $ns "table main 192.0.2.1/32 dev dummy1" true
check_err $? "Main table route in hardware when should not"
fib4_trap_check $ns "table local 192.0.2.1/32 dev dummy1" false
check_err $? "Local table route was replaced when should not"
# Test that local routes can replace routes in main table.
ip -n $ns route add table main 192.0.2.2/32 dev dummy1
fib4_trap_check $ns "table main 192.0.2.2/32 dev dummy1" false
check_err $? "Main table route not in hardware when should"
ip -n $ns route add table local 192.0.2.2/32 dev dummy1
fib4_trap_check $ns "table local 192.0.2.2/32 dev dummy1" false
check_err $? "Local table route did not replace route in main table when should"
fib4_trap_check $ns "table main 192.0.2.2/32 dev dummy1" true
check_err $? "Main table route was not replaced when should"
log_test "IPv4 local table route replacement"
ip -n $ns link del dev dummy1
}
ipv6_add()
{
fib_ipv6_add_test "testns1"
@@ -149,6 +188,43 @@ ipv6_replay_multipath()
fib_ipv6_replay_multipath_test "testns1" "$DEVLINK_DEV"
}
ipv6_local_replace()
{
local ns="testns1"
RET=0
ip -n $ns link add name dummy1 type dummy
ip -n $ns link set dev dummy1 up
ip -n $ns route add table local 2001:db8:1::1/128 dev dummy1
fib6_trap_check $ns "table local 2001:db8:1::1/128 dev dummy1" false
check_err $? "Local table route not in hardware when should"
ip -n $ns route add table main 2001:db8:1::1/128 dev dummy1
fib6_trap_check $ns "table main 2001:db8:1::1/128 dev dummy1" true
check_err $? "Main table route in hardware when should not"
fib6_trap_check $ns "table local 2001:db8:1::1/128 dev dummy1" false
check_err $? "Local table route was replaced when should not"
# Test that local routes can replace routes in main table.
ip -n $ns route add table main 2001:db8:1::2/128 dev dummy1
fib6_trap_check $ns "table main 2001:db8:1::2/128 dev dummy1" false
check_err $? "Main table route not in hardware when should"
ip -n $ns route add table local 2001:db8:1::2/128 dev dummy1
fib6_trap_check $ns "table local 2001:db8:1::2/128 dev dummy1" false
check_err $? "Local route route did not replace route in main table when should"
fib6_trap_check $ns "table main 2001:db8:1::2/128 dev dummy1" true
check_err $? "Main table route was not replaced when should"
log_test "IPv6 local table route replacement"
ip -n $ns link del dev dummy1
}
setup_prepare()
{
ip netns add testns1

View File

@@ -634,6 +634,14 @@ static void check_getpeername_connect(int fd)
cfg_host, a, cfg_port, b);
}
static void maybe_close(int fd)
{
unsigned int r = rand();
if (r & 1)
close(fd);
}
int main_loop_s(int listensock)
{
struct sockaddr_storage ss;
@@ -657,6 +665,7 @@ int main_loop_s(int listensock)
salen = sizeof(ss);
remotesock = accept(listensock, (struct sockaddr *)&ss, &salen);
if (remotesock >= 0) {
maybe_close(listensock);
check_sockaddr(pf, &ss, salen);
check_getpeername(remotesock, &ss, salen);

View File

@@ -38,9 +38,8 @@ ip0() { pretty 0 "ip $*"; ip -n $netns0 "$@"; }
ip1() { pretty 1 "ip $*"; ip -n $netns1 "$@"; }
ip2() { pretty 2 "ip $*"; ip -n $netns2 "$@"; }
sleep() { read -t "$1" -N 1 || true; }
waitiperf() { pretty "${1//*-}" "wait for iperf:5201"; while [[ $(ss -N "$1" -tlp 'sport = 5201') != *iperf3* ]]; do sleep 0.1; done; }
waitncatudp() { pretty "${1//*-}" "wait for udp:1111"; while [[ $(ss -N "$1" -ulp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
waitncattcp() { pretty "${1//*-}" "wait for tcp:1111"; while [[ $(ss -N "$1" -tlp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
waitiperf() { pretty "${1//*-}" "wait for iperf:5201 pid $2"; while [[ $(ss -N "$1" -tlpH 'sport = 5201') != *\"iperf3\",pid=$2,fd=* ]]; do sleep 0.1; done; }
waitncatudp() { pretty "${1//*-}" "wait for udp:1111 pid $2"; while [[ $(ss -N "$1" -ulpH 'sport = 1111') != *\"ncat\",pid=$2,fd=* ]]; do sleep 0.1; done; }
waitiface() { pretty "${1//*-}" "wait for $2 to come up"; ip netns exec "$1" bash -c "while [[ \$(< \"/sys/class/net/$2/operstate\") != up ]]; do read -t .1 -N 0 || true; done;"; }
cleanup() {
@@ -119,22 +118,22 @@ tests() {
# TCP over IPv4
n2 iperf3 -s -1 -B 192.168.241.2 &
waitiperf $netns2
waitiperf $netns2 $!
n1 iperf3 -Z -t 3 -c 192.168.241.2
# TCP over IPv6
n1 iperf3 -s -1 -B fd00::1 &
waitiperf $netns1
waitiperf $netns1 $!
n2 iperf3 -Z -t 3 -c fd00::1
# UDP over IPv4
n1 iperf3 -s -1 -B 192.168.241.1 &
waitiperf $netns1
waitiperf $netns1 $!
n2 iperf3 -Z -t 3 -b 0 -u -c 192.168.241.1
# UDP over IPv6
n2 iperf3 -s -1 -B fd00::2 &
waitiperf $netns2
waitiperf $netns2 $!
n1 iperf3 -Z -t 3 -b 0 -u -c fd00::2
}
@@ -207,7 +206,7 @@ n1 ping -W 1 -c 1 192.168.241.2
n1 wg set wg0 peer "$pub2" allowed-ips 192.168.241.0/24
exec 4< <(n1 ncat -l -u -p 1111)
ncat_pid=$!
waitncatudp $netns1
waitncatudp $netns1 $ncat_pid
n2 ncat -u 192.168.241.1 1111 <<<"X"
read -r -N 1 -t 1 out <&4 && [[ $out == "X" ]]
kill $ncat_pid
@@ -216,7 +215,7 @@ n1 wg set wg0 peer "$more_specific_key" allowed-ips 192.168.241.2/32
n2 wg set wg0 listen-port 9997
exec 4< <(n1 ncat -l -u -p 1111)
ncat_pid=$!
waitncatudp $netns1
waitncatudp $netns1 $ncat_pid
n2 ncat -u 192.168.241.1 1111 <<<"X"
! read -r -N 1 -t 1 out <&4 || false
kill $ncat_pid
@@ -516,6 +515,12 @@ n0 wg set wg0 peer "$pub2" allowed-ips 0.0.0.0/0,10.0.0.0/8,100.0.0.0/10,172.16.
n0 wg set wg0 peer "$pub2" allowed-ips 0.0.0.0/0
n0 wg set wg0 peer "$pub2" allowed-ips ::/0,1700::/111,5000::/4,e000::/37,9000::/75
n0 wg set wg0 peer "$pub2" allowed-ips ::/0
n0 wg set wg0 peer "$pub2" remove
low_order_points=( AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= 4Ot6fDtBuK4WVuP68Z/EatoJjeucMrH9hmIFFl9JuAA= X5yVvKNQjCSx0LFVnIPvWwREXMRYHI6G2CJO3dCfEVc= 7P///////////////////////////////////////38= 7f///////////////////////////////////////38= 7v///////////////////////////////////////38= )
n0 wg set wg0 private-key /dev/null ${low_order_points[@]/#/peer }
[[ -z $(n0 wg show wg0 peers) ]]
n0 wg set wg0 private-key <(echo "$key1") ${low_order_points[@]/#/peer }
[[ -z $(n0 wg show wg0 peers) ]]
ip0 link del wg0
declare -A objects

View File

@@ -1,5 +1,4 @@
CONFIG_LOCALVERSION="-debug"
CONFIG_ENABLE_WARN_DEPRECATED=y
CONFIG_ENABLE_MUST_CHECK=y
CONFIG_FRAME_POINTER=y
CONFIG_STACK_VALIDATION=y