Skip to content

Commit dc75a43

Browse files
committed
Merge tag 'nf-25-05-08' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter/IPVS fixes for net The following patchset contain Netfilter/IPVS fixes for net: 1) Fix KMSAN uninit-value in do_output_route4, reported by syzbot. Patch from Julian Anastasov. 2) ipset hashtable set type breaks up the hashtable into regions of 2^10 buckets. Fix the macro that determines the hashtable lock region to protect concurrent updates. From Jozsef Kadlecsik. * tag 'nf-25-05-08' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: ipset: fix region locking in hash types ipvs: fix uninit-value for saddr in do_output_route4 ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6beb683 + 8478a72 commit dc75a43

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

net/netfilter/ipset/ip_set_hash_gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct hbucket {
6464
#define ahash_sizeof_regions(htable_bits) \
6565
(ahash_numof_locks(htable_bits) * sizeof(struct ip_set_region))
6666
#define ahash_region(n, htable_bits) \
67-
((n) % ahash_numof_locks(htable_bits))
67+
((n) / jhash_size(HTABLE_REGION_BITS))
6868
#define ahash_bucket_start(h, htable_bits) \
6969
((htable_bits) < HTABLE_REGION_BITS ? 0 \
7070
: (h) * jhash_size(HTABLE_REGION_BITS))

net/netfilter/ipvs/ip_vs_xmit.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,12 @@ __mtu_check_toobig_v6(const struct sk_buff *skb, u32 mtu)
119119
return false;
120120
}
121121

122-
/* Get route to daddr, update *saddr, optionally bind route to saddr */
122+
/* Get route to daddr, optionally bind route to saddr */
123123
static struct rtable *do_output_route4(struct net *net, __be32 daddr,
124-
int rt_mode, __be32 *saddr)
124+
int rt_mode, __be32 *ret_saddr)
125125
{
126126
struct flowi4 fl4;
127127
struct rtable *rt;
128-
bool loop = false;
129128

130129
memset(&fl4, 0, sizeof(fl4));
131130
fl4.daddr = daddr;
@@ -135,23 +134,17 @@ static struct rtable *do_output_route4(struct net *net, __be32 daddr,
135134
retry:
136135
rt = ip_route_output_key(net, &fl4);
137136
if (IS_ERR(rt)) {
138-
/* Invalid saddr ? */
139-
if (PTR_ERR(rt) == -EINVAL && *saddr &&
140-
rt_mode & IP_VS_RT_MODE_CONNECT && !loop) {
141-
*saddr = 0;
142-
flowi4_update_output(&fl4, 0, daddr, 0);
143-
goto retry;
144-
}
145137
IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n", &daddr);
146138
return NULL;
147-
} else if (!*saddr && rt_mode & IP_VS_RT_MODE_CONNECT && fl4.saddr) {
139+
}
140+
if (rt_mode & IP_VS_RT_MODE_CONNECT && fl4.saddr) {
148141
ip_rt_put(rt);
149-
*saddr = fl4.saddr;
150142
flowi4_update_output(&fl4, 0, daddr, fl4.saddr);
151-
loop = true;
143+
rt_mode = 0;
152144
goto retry;
153145
}
154-
*saddr = fl4.saddr;
146+
if (ret_saddr)
147+
*ret_saddr = fl4.saddr;
155148
return rt;
156149
}
157150

@@ -344,19 +337,15 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb,
344337
if (ret_saddr)
345338
*ret_saddr = dest_dst->dst_saddr.ip;
346339
} else {
347-
__be32 saddr = htonl(INADDR_ANY);
348-
349340
noref = 0;
350341

351342
/* For such unconfigured boxes avoid many route lookups
352343
* for performance reasons because we do not remember saddr
353344
*/
354345
rt_mode &= ~IP_VS_RT_MODE_CONNECT;
355-
rt = do_output_route4(net, daddr, rt_mode, &saddr);
346+
rt = do_output_route4(net, daddr, rt_mode, ret_saddr);
356347
if (!rt)
357348
goto err_unreach;
358-
if (ret_saddr)
359-
*ret_saddr = saddr;
360349
}
361350

362351
local = (rt->rt_flags & RTCF_LOCAL) ? 1 : 0;

0 commit comments

Comments
 (0)