Skip to content

Commit 50ae879

Browse files
author
Paolo Abeni
committed
Merge tag 'nf-24-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== The following patchset contains Netfilter fixes for net: 1) Remove unused parameters in conntrack_dump_flush.c used by selftests, from Liu Jing. 2) Fix possible UaF when removing xtables module via getsockopt() interface, from Dong Chenchen. 3) Fix potential crash in nf_send_reset6() reported by syzkaller. From Eric Dumazet 4) Validate offset and length before calling skb_checksum() in nft_payload, otherwise hitting BUG() is possible. netfilter pull request 24-10-31 * tag 'nf-24-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nft_payload: sanitize offset and length before calling skb_checksum() netfilter: nf_reject_ipv6: fix potential crash in nf_send_reset6() netfilter: Fix use-after-free in get_info() selftests: netfilter: remove unused parameter ==================== Link: https://patch.msgid.link/ Signed-off-by: Paolo Abeni <[email protected]>
2 parents ee802a4 + d5953d6 commit 50ae879

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

net/ipv6/netfilter/nf_reject_ipv6.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ static int nf_reject6_fill_skb_dst(struct sk_buff *skb_in)
268268
void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
269269
int hook)
270270
{
271-
struct sk_buff *nskb;
272-
struct tcphdr _otcph;
273-
const struct tcphdr *otcph;
274-
unsigned int otcplen, hh_len;
275271
const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
276272
struct dst_entry *dst = NULL;
273+
const struct tcphdr *otcph;
274+
struct sk_buff *nskb;
275+
struct tcphdr _otcph;
276+
unsigned int otcplen;
277277
struct flowi6 fl6;
278278

279279
if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) ||
@@ -312,9 +312,8 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
312312
if (IS_ERR(dst))
313313
return;
314314

315-
hh_len = (dst->dev->hard_header_len + 15)&~15;
316-
nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr)
317-
+ sizeof(struct tcphdr) + dst->trailer_len,
315+
nskb = alloc_skb(LL_MAX_HEADER + sizeof(struct ipv6hdr) +
316+
sizeof(struct tcphdr) + dst->trailer_len,
318317
GFP_ATOMIC);
319318

320319
if (!nskb) {
@@ -327,7 +326,7 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
327326

328327
nskb->mark = fl6.flowi6_mark;
329328

330-
skb_reserve(nskb, hh_len + dst->header_len);
329+
skb_reserve(nskb, LL_MAX_HEADER);
331330
nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP, ip6_dst_hoplimit(dst));
332331
nf_reject_ip6_tcphdr_put(nskb, oldskb, otcph, otcplen);
333332

net/netfilter/nft_payload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
904904
((priv->base != NFT_PAYLOAD_TRANSPORT_HEADER &&
905905
priv->base != NFT_PAYLOAD_INNER_HEADER) ||
906906
skb->ip_summed != CHECKSUM_PARTIAL)) {
907+
if (offset + priv->len > skb->len)
908+
goto err;
909+
907910
fsum = skb_checksum(skb, offset, priv->len, 0);
908911
tsum = csum_partial(src, priv->len, 0);
909912

net/netfilter/x_tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
12691269

12701270
/* and once again: */
12711271
list_for_each_entry(t, &xt_net->tables[af], list)
1272-
if (strcmp(t->name, name) == 0)
1272+
if (strcmp(t->name, name) == 0 && owner == t->me)
12731273
return t;
12741274

12751275
module_put(owner);

tools/testing/selftests/net/netfilter/conntrack_dump_flush.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int conntrack_data_insert(struct mnl_socket *sock, struct nlmsghdr *nlh,
9898
char buf[MNL_SOCKET_BUFFER_SIZE];
9999
struct nlmsghdr *rplnlh;
100100
unsigned int portid;
101-
int err, ret;
101+
int ret;
102102

103103
portid = mnl_socket_get_portid(sock);
104104

@@ -217,7 +217,7 @@ static int conntracK_count_zone(struct mnl_socket *sock, uint16_t zone)
217217
struct nfgenmsg *nfh;
218218
struct nlattr *nest;
219219
unsigned int portid;
220-
int err, ret;
220+
int ret;
221221

222222
portid = mnl_socket_get_portid(sock);
223223

@@ -264,7 +264,7 @@ static int conntrack_flush_zone(struct mnl_socket *sock, uint16_t zone)
264264
struct nfgenmsg *nfh;
265265
struct nlattr *nest;
266266
unsigned int portid;
267-
int err, ret;
267+
int ret;
268268

269269
portid = mnl_socket_get_portid(sock);
270270

0 commit comments

Comments
 (0)