Skip to content

Commit f6a2a31

Browse files
committed
Merge tag 'nf-25-08-07' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Reinstantiate Florian Westphal as a Netfilter maintainer. 2) Depend on both NETFILTER_XTABLES and NETFILTER_XTABLES_LEGACY, from Arnd Bergmann. 3) Use id to annotate last conntrack/expectation visited to resume netlink dump, patches from Florian Westphal. 4) Fix bogus element in nft_pipapo avx2 lookup, introduced in the last nf-next batch of updates, also from Florian. 5) Return 0 instead of recycling ret variable in nf_conntrack_log_invalid_sysctl(), introduced in the last nf-next batch of updates, from Dan Carpenter. 6) Fix WARN_ON_ONCE triggered by syzbot with larger cgroup level in nft_socket. * tag 'nf-25-08-07' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nft_socket: remove WARN_ON_ONCE with huge level value netfilter: conntrack: clean up returns in nf_conntrack_log_invalid_sysctl() netfilter: nft_set_pipapo: don't return bogus extension pointer netfilter: ctnetlink: remove refcounting in expectation dumpers netfilter: ctnetlink: fix refcount leak on table dump netfilter: add back NETFILTER_XTABLES dependencies MAINTAINERS: resurrect my netfilter maintainer entry ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 3781648 + 1dee968 commit f6a2a31

File tree

8 files changed

+46
-45
lines changed

8 files changed

+46
-45
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17451,6 +17451,7 @@ F: drivers/net/ethernet/neterion/
1745117451
NETFILTER
1745217452
M: Pablo Neira Ayuso <[email protected]>
1745317453
M: Jozsef Kadlecsik <[email protected]>
17454+
M: Florian Westphal <[email protected]>
1745417455
1745517456
1745617457
S: Maintained

net/bridge/netfilter/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config NF_CONNTRACK_BRIDGE
4343
config BRIDGE_NF_EBTABLES_LEGACY
4444
tristate "Legacy EBTABLES support"
4545
depends on BRIDGE && NETFILTER_XTABLES_LEGACY
46+
depends on NETFILTER_XTABLES
4647
default n
4748
help
4849
Legacy ebtables packet/frame classifier.

net/ipv4/netfilter/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config NF_DEFRAG_IPV4
1414
config IP_NF_IPTABLES_LEGACY
1515
tristate "Legacy IP tables support"
1616
depends on NETFILTER_XTABLES_LEGACY
17+
depends on NETFILTER_XTABLES
1718
default m if NETFILTER_XTABLES_LEGACY
1819
help
1920
iptables is a legacy packet classifier.
@@ -326,6 +327,7 @@ endif # IP_NF_IPTABLES
326327
config IP_NF_ARPTABLES
327328
tristate "Legacy ARPTABLES support"
328329
depends on NETFILTER_XTABLES_LEGACY
330+
depends on NETFILTER_XTABLES
329331
default n
330332
help
331333
arptables is a legacy packet classifier.
@@ -343,6 +345,7 @@ config IP_NF_ARPFILTER
343345
select IP_NF_ARPTABLES
344346
select NETFILTER_FAMILY_ARP
345347
depends on NETFILTER_XTABLES_LEGACY
348+
depends on NETFILTER_XTABLES
346349
help
347350
ARP packet filtering defines a table `filter', which has a series of
348351
rules for simple ARP packet filtering at local input and

net/ipv6/netfilter/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ menu "IPv6: Netfilter Configuration"
1010
config IP6_NF_IPTABLES_LEGACY
1111
tristate "Legacy IP6 tables support"
1212
depends on INET && IPV6 && NETFILTER_XTABLES_LEGACY
13+
depends on NETFILTER_XTABLES
1314
default m if NETFILTER_XTABLES_LEGACY
1415
help
1516
ip6tables is a legacy packet classifier.

net/netfilter/nf_conntrack_netlink.c

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,6 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
884884

885885
static int ctnetlink_done(struct netlink_callback *cb)
886886
{
887-
if (cb->args[1])
888-
nf_ct_put((struct nf_conn *)cb->args[1]);
889887
kfree(cb->data);
890888
return 0;
891889
}
@@ -1208,19 +1206,26 @@ static int ctnetlink_filter_match(struct nf_conn *ct, void *data)
12081206
return 0;
12091207
}
12101208

1209+
static unsigned long ctnetlink_get_id(const struct nf_conn *ct)
1210+
{
1211+
unsigned long id = nf_ct_get_id(ct);
1212+
1213+
return id ? id : 1;
1214+
}
1215+
12111216
static int
12121217
ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
12131218
{
12141219
unsigned int flags = cb->data ? NLM_F_DUMP_FILTERED : 0;
12151220
struct net *net = sock_net(skb->sk);
1216-
struct nf_conn *ct, *last;
1221+
unsigned long last_id = cb->args[1];
12171222
struct nf_conntrack_tuple_hash *h;
12181223
struct hlist_nulls_node *n;
12191224
struct nf_conn *nf_ct_evict[8];
1225+
struct nf_conn *ct;
12201226
int res, i;
12211227
spinlock_t *lockp;
12221228

1223-
last = (struct nf_conn *)cb->args[1];
12241229
i = 0;
12251230

12261231
local_bh_disable();
@@ -1257,7 +1262,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
12571262
continue;
12581263

12591264
if (cb->args[1]) {
1260-
if (ct != last)
1265+
if (ctnetlink_get_id(ct) != last_id)
12611266
continue;
12621267
cb->args[1] = 0;
12631268
}
@@ -1270,8 +1275,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
12701275
NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
12711276
ct, true, flags);
12721277
if (res < 0) {
1273-
nf_conntrack_get(&ct->ct_general);
1274-
cb->args[1] = (unsigned long)ct;
1278+
cb->args[1] = ctnetlink_get_id(ct);
12751279
spin_unlock(lockp);
12761280
goto out;
12771281
}
@@ -1284,12 +1288,10 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
12841288
}
12851289
out:
12861290
local_bh_enable();
1287-
if (last) {
1291+
if (last_id) {
12881292
/* nf ct hash resize happened, now clear the leftover. */
1289-
if ((struct nf_conn *)cb->args[1] == last)
1293+
if (cb->args[1] == last_id)
12901294
cb->args[1] = 0;
1291-
1292-
nf_ct_put(last);
12931295
}
12941296

12951297
while (i) {
@@ -3168,23 +3170,27 @@ ctnetlink_expect_event(unsigned int events, const struct nf_exp_event *item)
31683170
return 0;
31693171
}
31703172
#endif
3171-
static int ctnetlink_exp_done(struct netlink_callback *cb)
3173+
3174+
static unsigned long ctnetlink_exp_id(const struct nf_conntrack_expect *exp)
31723175
{
3173-
if (cb->args[1])
3174-
nf_ct_expect_put((struct nf_conntrack_expect *)cb->args[1]);
3175-
return 0;
3176+
unsigned long id = (unsigned long)exp;
3177+
3178+
id += nf_ct_get_id(exp->master);
3179+
id += exp->class;
3180+
3181+
return id ? id : 1;
31763182
}
31773183

31783184
static int
31793185
ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
31803186
{
31813187
struct net *net = sock_net(skb->sk);
3182-
struct nf_conntrack_expect *exp, *last;
31833188
struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
31843189
u_int8_t l3proto = nfmsg->nfgen_family;
3190+
unsigned long last_id = cb->args[1];
3191+
struct nf_conntrack_expect *exp;
31853192

31863193
rcu_read_lock();
3187-
last = (struct nf_conntrack_expect *)cb->args[1];
31883194
for (; cb->args[0] < nf_ct_expect_hsize; cb->args[0]++) {
31893195
restart:
31903196
hlist_for_each_entry_rcu(exp, &nf_ct_expect_hash[cb->args[0]],
@@ -3196,7 +3202,7 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
31963202
continue;
31973203

31983204
if (cb->args[1]) {
3199-
if (exp != last)
3205+
if (ctnetlink_exp_id(exp) != last_id)
32003206
continue;
32013207
cb->args[1] = 0;
32023208
}
@@ -3205,9 +3211,7 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
32053211
cb->nlh->nlmsg_seq,
32063212
IPCTNL_MSG_EXP_NEW,
32073213
exp) < 0) {
3208-
if (!refcount_inc_not_zero(&exp->use))
3209-
continue;
3210-
cb->args[1] = (unsigned long)exp;
3214+
cb->args[1] = ctnetlink_exp_id(exp);
32113215
goto out;
32123216
}
32133217
}
@@ -3218,42 +3222,38 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
32183222
}
32193223
out:
32203224
rcu_read_unlock();
3221-
if (last)
3222-
nf_ct_expect_put(last);
3223-
32243225
return skb->len;
32253226
}
32263227

32273228
static int
32283229
ctnetlink_exp_ct_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
32293230
{
3230-
struct nf_conntrack_expect *exp, *last;
32313231
struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
32323232
struct nf_conn *ct = cb->data;
32333233
struct nf_conn_help *help = nfct_help(ct);
32343234
u_int8_t l3proto = nfmsg->nfgen_family;
3235+
unsigned long last_id = cb->args[1];
3236+
struct nf_conntrack_expect *exp;
32353237

32363238
if (cb->args[0])
32373239
return 0;
32383240

32393241
rcu_read_lock();
3240-
last = (struct nf_conntrack_expect *)cb->args[1];
3242+
32413243
restart:
32423244
hlist_for_each_entry_rcu(exp, &help->expectations, lnode) {
32433245
if (l3proto && exp->tuple.src.l3num != l3proto)
32443246
continue;
32453247
if (cb->args[1]) {
3246-
if (exp != last)
3248+
if (ctnetlink_exp_id(exp) != last_id)
32473249
continue;
32483250
cb->args[1] = 0;
32493251
}
32503252
if (ctnetlink_exp_fill_info(skb, NETLINK_CB(cb->skb).portid,
32513253
cb->nlh->nlmsg_seq,
32523254
IPCTNL_MSG_EXP_NEW,
32533255
exp) < 0) {
3254-
if (!refcount_inc_not_zero(&exp->use))
3255-
continue;
3256-
cb->args[1] = (unsigned long)exp;
3256+
cb->args[1] = ctnetlink_exp_id(exp);
32573257
goto out;
32583258
}
32593259
}
@@ -3264,9 +3264,6 @@ ctnetlink_exp_ct_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
32643264
cb->args[0] = 1;
32653265
out:
32663266
rcu_read_unlock();
3267-
if (last)
3268-
nf_ct_expect_put(last);
3269-
32703267
return skb->len;
32713268
}
32723269

@@ -3285,7 +3282,6 @@ static int ctnetlink_dump_exp_ct(struct net *net, struct sock *ctnl,
32853282
struct nf_conntrack_zone zone;
32863283
struct netlink_dump_control c = {
32873284
.dump = ctnetlink_exp_ct_dump_table,
3288-
.done = ctnetlink_exp_done,
32893285
};
32903286

32913287
err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_MASTER,
@@ -3335,7 +3331,6 @@ static int ctnetlink_get_expect(struct sk_buff *skb,
33353331
else {
33363332
struct netlink_dump_control c = {
33373333
.dump = ctnetlink_exp_dump_table,
3338-
.done = ctnetlink_exp_done,
33393334
};
33403335
return netlink_dump_start(info->sk, skb, info->nlh, &c);
33413336
}

net/netfilter/nf_conntrack_standalone.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,16 @@ nf_conntrack_log_invalid_sysctl(const struct ctl_table *table, int write,
567567
return ret;
568568

569569
if (*(u8 *)table->data == 0)
570-
return ret;
570+
return 0;
571571

572572
/* Load nf_log_syslog only if no logger is currently registered */
573573
for (i = 0; i < NFPROTO_NUMPROTO; i++) {
574574
if (nf_log_is_registered(i))
575-
return ret;
575+
return 0;
576576
}
577577
request_module("%s", "nf_log_syslog");
578578

579-
return ret;
579+
return 0;
580580
}
581581

582582
static struct ctl_table_header *nf_ct_netfilter_header;

net/netfilter/nft_set_pipapo_avx2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,12 +1150,12 @@ nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
11501150
const u32 *key)
11511151
{
11521152
struct nft_pipapo *priv = nft_set_priv(set);
1153+
const struct nft_set_ext *ext = NULL;
11531154
struct nft_pipapo_scratch *scratch;
11541155
u8 genmask = nft_genmask_cur(net);
11551156
const struct nft_pipapo_match *m;
11561157
const struct nft_pipapo_field *f;
11571158
const u8 *rp = (const u8 *)key;
1158-
const struct nft_set_ext *ext;
11591159
unsigned long *res, *fill;
11601160
bool map_index;
11611161
int i;
@@ -1246,13 +1246,13 @@ nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
12461246
goto out;
12471247

12481248
if (last) {
1249-
ext = &f->mt[ret].e->ext;
1250-
if (unlikely(nft_set_elem_expired(ext) ||
1251-
!nft_set_elem_active(ext, genmask))) {
1252-
ext = NULL;
1249+
const struct nft_set_ext *e = &f->mt[ret].e->ext;
1250+
1251+
if (unlikely(nft_set_elem_expired(e) ||
1252+
!nft_set_elem_active(e, genmask)))
12531253
goto next_match;
1254-
}
12551254

1255+
ext = e;
12561256
goto out;
12571257
}
12581258

net/netfilter/nft_socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int nft_socket_init(const struct nft_ctx *ctx,
217217

218218
level += err;
219219
/* Implies a giant cgroup tree */
220-
if (WARN_ON_ONCE(level > 255))
220+
if (level > 255)
221221
return -EOPNOTSUPP;
222222

223223
priv->level = level;

0 commit comments

Comments
 (0)