Skip to content

Commit fa28755

Browse files
author
Paolo Abeni
committed
Merge tag 'nf-24-10-21' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== This patchset contains Netfilter fixes for net: 1) syzkaller managed to triger UaF due to missing reference on netns in bpf infrastructure, from Florian Westphal. 2) Fix incorrect conversion from NFPROTO_UNSPEC to NFPROTO_{IPV4,IPV6} in the following xtables targets: MARK and NFLOG. Moreover, add missing I have my half share in this mistake, I did not take the necessary time to review this: For several years I have been struggling to keep working on Netfilter, juggling a myriad of side consulting projects to stop burning my own savings. I have extended the iptables-tests.py test infrastructure to improve the coverage of ip6tables and detect similar problems in the future. This is a v2 including a extended PR with one more fix. netfilter pull request 24-10-21 * tag 'nf-24-10-21' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: xtables: fix typo causing some targets not to load on IPv6 netfilter: bpf: must hold reference on net namespace ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents d95d9a3 + 306ed17 commit fa28755

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

net/netfilter/nf_bpf_link.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static unsigned int nf_hook_run_bpf(void *bpf_prog, struct sk_buff *skb,
2323
struct bpf_nf_link {
2424
struct bpf_link link;
2525
struct nf_hook_ops hook_ops;
26+
netns_tracker ns_tracker;
2627
struct net *net;
2728
u32 dead;
2829
const struct nf_defrag_hook *defrag_hook;
@@ -120,6 +121,7 @@ static void bpf_nf_link_release(struct bpf_link *link)
120121
if (!cmpxchg(&nf_link->dead, 0, 1)) {
121122
nf_unregister_net_hook(nf_link->net, &nf_link->hook_ops);
122123
bpf_nf_disable_defrag(nf_link);
124+
put_net_track(nf_link->net, &nf_link->ns_tracker);
123125
}
124126
}
125127

@@ -257,6 +259,8 @@ int bpf_nf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
257259
return err;
258260
}
259261

262+
get_net_track(net, &link->ns_tracker, GFP_KERNEL);
263+
260264
return bpf_link_settle(&link_primer);
261265
}
262266

net/netfilter/xt_NFLOG.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static struct xt_target nflog_tg_reg[] __read_mostly = {
7979
{
8080
.name = "NFLOG",
8181
.revision = 0,
82-
.family = NFPROTO_IPV4,
82+
.family = NFPROTO_IPV6,
8383
.checkentry = nflog_tg_check,
8484
.destroy = nflog_tg_destroy,
8585
.target = nflog_tg,

net/netfilter/xt_TRACE.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static struct xt_target trace_tg_reg[] __read_mostly = {
4949
.target = trace_tg,
5050
.checkentry = trace_tg_check,
5151
.destroy = trace_tg_destroy,
52+
.me = THIS_MODULE,
5253
},
5354
#endif
5455
};

net/netfilter/xt_mark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = {
6262
{
6363
.name = "MARK",
6464
.revision = 2,
65-
.family = NFPROTO_IPV4,
65+
.family = NFPROTO_IPV6,
6666
.target = mark_tg,
6767
.targetsize = sizeof(struct xt_mark_tginfo2),
6868
.me = THIS_MODULE,

0 commit comments

Comments
 (0)