Skip to content

Commit 55bc1af

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net 1) Add SECMARK revision 1 to fix incorrect layout that prevents from remove rule with this target, from Phil Sutter. 2) Fix pernet exit path spat in arptables, from Florian Westphal. 3) Missing rcu_read_unlock() for unknown nfnetlink callbacks, reported by syzbot, from Eric Dumazet. 4) Missing check for skb_header_pointer() NULL pointer in nfnetlink_osf. 5) Remove BUG_ON() after skb_header_pointer() from packet path in several conntrack helper and the TCP tracker. 6) Fix memleak in the new object error path of userdata. 7) Avoid overflows in nft_hash_buckets(), reported by syzbot, also from Eric. 8) Avoid overflows in 32bit arches, from Eric. * git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf: netfilter: nftables: avoid potential overflows on 32bit arches netfilter: nftables: avoid overflows in nft_hash_buckets() netfilter: nftables: Fix a memleak from userdata error path in new objects netfilter: remove BUG_ON() after skb_header_pointer() netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check netfilter: nfnetlink: add a missing rcu_read_unlock() netfilter: arptables: use pernet ops struct during unregister netfilter: xt_SECMARK: add new revision to fix structure layout ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents e4d4a27 + 6c8774a commit 55bc1af

File tree

15 files changed

+124
-42
lines changed

15 files changed

+124
-42
lines changed

include/linux/netfilter_arp/arp_tables.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ int arpt_register_table(struct net *net, const struct xt_table *table,
5353
const struct arpt_replace *repl,
5454
const struct nf_hook_ops *ops);
5555
void arpt_unregister_table(struct net *net, const char *name);
56-
void arpt_unregister_table_pre_exit(struct net *net, const char *name,
57-
const struct nf_hook_ops *ops);
56+
void arpt_unregister_table_pre_exit(struct net *net, const char *name);
5857
extern unsigned int arpt_do_table(struct sk_buff *skb,
5958
const struct nf_hook_state *state,
6059
struct xt_table *table);

include/uapi/linux/netfilter/xt_SECMARK.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ struct xt_secmark_target_info {
2020
char secctx[SECMARK_SECCTX_MAX];
2121
};
2222

23+
struct xt_secmark_target_info_v1 {
24+
__u8 mode;
25+
char secctx[SECMARK_SECCTX_MAX];
26+
__u32 secid;
27+
};
28+
2329
#endif /*_XT_SECMARK_H_target */

net/ipv4/netfilter/arp_tables.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,13 +1556,12 @@ int arpt_register_table(struct net *net,
15561556
return ret;
15571557
}
15581558

1559-
void arpt_unregister_table_pre_exit(struct net *net, const char *name,
1560-
const struct nf_hook_ops *ops)
1559+
void arpt_unregister_table_pre_exit(struct net *net, const char *name)
15611560
{
15621561
struct xt_table *table = xt_find_table(net, NFPROTO_ARP, name);
15631562

15641563
if (table)
1565-
nf_unregister_net_hooks(net, ops, hweight32(table->valid_hooks));
1564+
nf_unregister_net_hooks(net, table->ops, hweight32(table->valid_hooks));
15661565
}
15671566
EXPORT_SYMBOL(arpt_unregister_table_pre_exit);
15681567

net/ipv4/netfilter/arptable_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int __net_init arptable_filter_table_init(struct net *net)
5454

5555
static void __net_exit arptable_filter_net_pre_exit(struct net *net)
5656
{
57-
arpt_unregister_table_pre_exit(net, "filter", arpfilter_ops);
57+
arpt_unregister_table_pre_exit(net, "filter");
5858
}
5959

6060
static void __net_exit arptable_filter_net_exit(struct net *net)

net/netfilter/nf_conntrack_ftp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,10 @@ static int help(struct sk_buff *skb,
413413

414414
spin_lock_bh(&nf_ftp_lock);
415415
fb_ptr = skb_header_pointer(skb, dataoff, datalen, ftp_buffer);
416-
BUG_ON(fb_ptr == NULL);
416+
if (!fb_ptr) {
417+
spin_unlock_bh(&nf_ftp_lock);
418+
return NF_ACCEPT;
419+
}
417420

418421
ends_in_nl = (fb_ptr[datalen - 1] == '\n');
419422
seq = ntohl(th->seq) + datalen;

net/netfilter/nf_conntrack_h323_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ static int get_tpkt_data(struct sk_buff *skb, unsigned int protoff,
146146
/* Get first TPKT pointer */
147147
tpkt = skb_header_pointer(skb, tcpdataoff, tcpdatalen,
148148
h323_buffer);
149-
BUG_ON(tpkt == NULL);
149+
if (!tpkt)
150+
goto clear_out;
150151

151152
/* Validate TPKT identifier */
152153
if (tcpdatalen < 4 || tpkt[0] != 0x03 || tpkt[1] != 0) {

net/netfilter/nf_conntrack_irc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ static int help(struct sk_buff *skb, unsigned int protoff,
143143
spin_lock_bh(&irc_buffer_lock);
144144
ib_ptr = skb_header_pointer(skb, dataoff, skb->len - dataoff,
145145
irc_buffer);
146-
BUG_ON(ib_ptr == NULL);
146+
if (!ib_ptr) {
147+
spin_unlock_bh(&irc_buffer_lock);
148+
return NF_ACCEPT;
149+
}
147150

148151
data = ib_ptr;
149152
data_limit = ib_ptr + skb->len - dataoff;

net/netfilter/nf_conntrack_pptp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,9 @@ conntrack_pptp_help(struct sk_buff *skb, unsigned int protoff,
544544

545545
nexthdr_off = protoff;
546546
tcph = skb_header_pointer(skb, nexthdr_off, sizeof(_tcph), &_tcph);
547-
BUG_ON(!tcph);
547+
if (!tcph)
548+
return NF_ACCEPT;
549+
548550
nexthdr_off += tcph->doff * 4;
549551
datalen = tcplen - tcph->doff * 4;
550552

net/netfilter/nf_conntrack_proto_tcp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ static void tcp_options(const struct sk_buff *skb,
338338

339339
ptr = skb_header_pointer(skb, dataoff + sizeof(struct tcphdr),
340340
length, buff);
341-
BUG_ON(ptr == NULL);
341+
if (!ptr)
342+
return;
342343

343344
state->td_scale =
344345
state->flags = 0;
@@ -394,7 +395,8 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
394395

395396
ptr = skb_header_pointer(skb, dataoff + sizeof(struct tcphdr),
396397
length, buff);
397-
BUG_ON(ptr == NULL);
398+
if (!ptr)
399+
return;
398400

399401
/* Fast path for timestamp-only option */
400402
if (length == TCPOLEN_TSTAMP_ALIGNED

net/netfilter/nf_conntrack_sane.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ static int help(struct sk_buff *skb,
9595

9696
spin_lock_bh(&nf_sane_lock);
9797
sb_ptr = skb_header_pointer(skb, dataoff, datalen, sane_buffer);
98-
BUG_ON(sb_ptr == NULL);
98+
if (!sb_ptr) {
99+
spin_unlock_bh(&nf_sane_lock);
100+
return NF_ACCEPT;
101+
}
99102

100103
if (dir == IP_CT_DIR_ORIGINAL) {
101104
if (datalen != sizeof(struct sane_request))

0 commit comments

Comments
 (0)