Skip to content

Commit 2950714

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Refcount leak in ipt_CLUSTERIP rule loading path, from Xin Xiong. 2) Use socat in netfilter selftests, from Hangbin Liu. 3) Skip layer checksum 4 update for IP fragments. 4) Missing allocation of pcpu scratch maps on clone in nft_set_pipapo, from Florian Westphal. * git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf: netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone netfilter: nft_payload: do not update layer 4 checksum when mangling fragments selftests: netfilter: switch to socat for tests using -q option netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 36595d8 + 23c5426 commit 2950714

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

net/ipv4/netfilter/ipt_CLUSTERIP.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,11 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par)
520520
if (IS_ERR(config))
521521
return PTR_ERR(config);
522522
}
523-
} else if (memcmp(&config->clustermac, &cipinfo->clustermac, ETH_ALEN))
523+
} else if (memcmp(&config->clustermac, &cipinfo->clustermac, ETH_ALEN)) {
524+
clusterip_config_entry_put(config);
525+
clusterip_config_put(config);
524526
return -EINVAL;
527+
}
525528

526529
ret = nf_ct_netns_get(par->net, par->family);
527530
if (ret < 0) {

net/netfilter/nft_payload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,9 @@ static int nft_payload_l4csum_offset(const struct nft_pktinfo *pkt,
546546
struct sk_buff *skb,
547547
unsigned int *l4csum_offset)
548548
{
549+
if (pkt->fragoff)
550+
return -1;
551+
549552
switch (pkt->tprot) {
550553
case IPPROTO_TCP:
551554
*l4csum_offset = offsetof(struct tcphdr, check);

net/netfilter/nft_set_pipapo.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
12901290
if (!new->scratch_aligned)
12911291
goto out_scratch;
12921292
#endif
1293+
for_each_possible_cpu(i)
1294+
*per_cpu_ptr(new->scratch, i) = NULL;
1295+
1296+
if (pipapo_realloc_scratch(new, old->bsize_max))
1297+
goto out_scratch_realloc;
12931298

12941299
rcu_head_init(&new->rcu);
12951300

@@ -1334,6 +1339,9 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
13341339
kvfree(dst->lt);
13351340
dst--;
13361341
}
1342+
out_scratch_realloc:
1343+
for_each_possible_cpu(i)
1344+
kfree(*per_cpu_ptr(new->scratch, i));
13371345
#ifdef NFT_PIPAPO_ALIGN
13381346
free_percpu(new->scratch_aligned);
13391347
#endif

tools/testing/selftests/netfilter/ipip-conntrack-mtu.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ checktool (){
4141

4242
checktool "iptables --version" "run test without iptables"
4343
checktool "ip -Version" "run test without ip tool"
44-
checktool "which nc" "run test without nc (netcat)"
44+
checktool "which socat" "run test without socat"
4545
checktool "ip netns add ${r_a}" "create net namespace"
4646

4747
for n in ${r_b} ${r_w} ${c_a} ${c_b};do
@@ -60,11 +60,12 @@ trap cleanup EXIT
6060
test_path() {
6161
msg="$1"
6262

63-
ip netns exec ${c_b} nc -n -w 3 -q 3 -u -l -p 5000 > ${rx} < /dev/null &
63+
ip netns exec ${c_b} socat -t 3 - udp4-listen:5000,reuseaddr > ${rx} < /dev/null &
6464

6565
sleep 1
6666
for i in 1 2 3; do
67-
head -c1400 /dev/zero | tr "\000" "a" | ip netns exec ${c_a} nc -n -w 1 -u 192.168.20.2 5000
67+
head -c1400 /dev/zero | tr "\000" "a" | \
68+
ip netns exec ${c_a} socat -t 1 -u STDIN UDP:192.168.20.2:5000
6869
done
6970

7071
wait
@@ -189,7 +190,7 @@ ip netns exec ${r_w} sysctl -q net.ipv4.conf.all.forwarding=1 > /dev/null
189190
#---------------------
190191
#Now we send a 1400 bytes UDP packet from Client A to Client B:
191192

192-
# clienta:~# head -c1400 /dev/zero | tr "\000" "a" | nc -u 192.168.20.2 5000
193+
# clienta:~# head -c1400 /dev/zero | tr "\000" "a" | socat -u STDIN UDP:192.168.20.2:5000
193194
test_path "without"
194195

195196
# The IPv4 stack on Client A already knows the PMTU to Client B, so the

tools/testing/selftests/netfilter/nf_nat_edemux.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,23 @@ ip netns exec $ns2 ip route add 10.96.0.1 via 192.168.1.1
7676
sleep 1
7777

7878
# add a persistent connection from the other namespace
79-
ip netns exec $ns2 nc -q 10 -w 10 192.168.1.1 5201 > /dev/null &
79+
ip netns exec $ns2 socat -t 10 - TCP:192.168.1.1:5201 > /dev/null &
8080

8181
sleep 1
8282

8383
# ip daddr:dport will be rewritten to 192.168.1.1 5201
8484
# NAT must reallocate source port 10000 because
8585
# 192.168.1.2:10000 -> 192.168.1.1:5201 is already in use
86-
echo test | ip netns exec $ns2 nc -w 3 -q 3 10.96.0.1 443 >/dev/null
86+
echo test | ip netns exec $ns2 socat -t 3 -u STDIN TCP:10.96.0.1:443 >/dev/null
8787
ret=$?
8888

8989
kill $iperfs
9090

91-
# Check nc can connect to 10.96.0.1:443 (aka 192.168.1.1:5201).
91+
# Check socat can connect to 10.96.0.1:443 (aka 192.168.1.1:5201).
9292
if [ $ret -eq 0 ]; then
93-
echo "PASS: nc can connect via NAT'd address"
93+
echo "PASS: socat can connect via NAT'd address"
9494
else
95-
echo "FAIL: nc cannot connect via NAT'd address"
95+
echo "FAIL: socat cannot connect via NAT'd address"
9696
exit 1
9797
fi
9898

0 commit comments

Comments
 (0)