Skip to content

Commit ead0540

Browse files
committed
Florian Westphal says: ==================== netfilter: updates for net Due to large volume of backlogged patches its unlikely I will make the 2nd planned PR this week, so several legit fixes will be pushed back to next week. Sorry for the inconvenience but I am out of ideas and alternatives. 1) syzbot managed to add/remove devices to a flowtable, due to a bug in the flowtable netdevice notifier this gets us a double-add and eventually UaF when device is removed again (we only expect one entry, duplicate remains past net_device end-of-life). From Phil Sutter, bug added in 6.16. 2) Yiming Qian reports another nf_tables transaction handling bug: in some cases error unwind misses to undo certain set elements, resulting in refcount underflow and use-after-free, bug added in 6.4. 3) Jenny Guanni Qu found out-of-bounds read in pipapo set type. While the value is never used, it still rightfully triggers KASAN splats. Bug exists since this set type was added in 5.6. 4) a few x_tables modules contain copypastry tcp option parsing code which can read 1 byte past the option area. This bug is ancient, fix from David Dull. 5) nfnetlink_queue leaks kernel memory if userspace provides bad NFQA_VLAN/NFQA_L2HDR attributes. From Hyunwoo Kim, bug stems from from 4.7 days. 6) nfnetlink_cthelper has incorrect loop restart logic which may result in reading one pointer past end of array. From 3.6 days, fix also from Hyunwoo Kim. 7) xt_IDLETIMER v0 extension must reject working with timers added by revision v1, else we get list corruption. Bug added in v5.7. From Yifan Wu, Juefei Pu and Yuan Tan via Xin Lu. * tag 'nf-26-03-10' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: xt_IDLETIMER: reject rev0 reuse of ALARM timer labels netfilter: nfnetlink_cthelper: fix OOB read in nfnl_cthelper_dump_table() netfilter: nfnetlink_queue: fix entry leak in bridge verdict error path netfilter: x_tables: guard option walkers against 1-byte tail reads netfilter: nft_set_pipapo: fix stack out-of-bounds read in pipapo_drop() netfilter: nf_tables: always walk all pending catchall elements netfilter: nf_tables: Fix for duplicate device in netdev hooks ==================== Link: https://patch.msgid.link/20260310132050.630-1-fw@strlen.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 14ad510 + 329f0b9 commit ead0540

8 files changed

Lines changed: 23 additions & 14 deletions

File tree

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ static void nft_map_catchall_deactivate(const struct nft_ctx *ctx,
829829

830830
nft_set_elem_change_active(ctx->net, set, ext);
831831
nft_setelem_data_deactivate(ctx->net, set, catchall->elem);
832-
break;
833832
}
834833
}
835834

@@ -5873,7 +5872,6 @@ static void nft_map_catchall_activate(const struct nft_ctx *ctx,
58735872

58745873
nft_clear(ctx->net, ext);
58755874
nft_setelem_data_activate(ctx->net, set, catchall->elem);
5876-
break;
58775875
}
58785876
}
58795877

@@ -9688,7 +9686,7 @@ static int nft_flowtable_event(unsigned long event, struct net_device *dev,
96889686
break;
96899687
case NETDEV_REGISTER:
96909688
/* NOP if not matching or already registered */
9691-
if (!match || (changename && ops))
9689+
if (!match || ops)
96929690
continue;
96939691

96949692
ops = kzalloc_obj(struct nf_hook_ops,

net/netfilter/nfnetlink_cthelper.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,10 @@ nfnl_cthelper_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
601601
goto out;
602602
}
603603
}
604-
}
605-
if (cb->args[1]) {
606-
cb->args[1] = 0;
607-
goto restart;
604+
if (cb->args[1]) {
605+
cb->args[1] = 0;
606+
goto restart;
607+
}
608608
}
609609
out:
610610
rcu_read_unlock();

net/netfilter/nfnetlink_queue.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,10 @@ static int nfqnl_recv_verdict(struct sk_buff *skb, const struct nfnl_info *info,
15461546

15471547
if (entry->state.pf == PF_BRIDGE) {
15481548
err = nfqa_parse_bridge(entry, nfqa);
1549-
if (err < 0)
1549+
if (err < 0) {
1550+
nfqnl_reinject(entry, NF_DROP);
15501551
return err;
1552+
}
15511553
}
15521554

15531555
if (nfqa[NFQA_PAYLOAD]) {

net/netfilter/nft_chain_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static int nft_netdev_event(unsigned long event, struct net_device *dev,
344344
break;
345345
case NETDEV_REGISTER:
346346
/* NOP if not matching or already registered */
347-
if (!match || (changename && ops))
347+
if (!match || ops)
348348
continue;
349349

350350
ops = kmemdup(&basechain->ops,

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,7 @@ static void pipapo_drop(struct nft_pipapo_match *m,
16401640
int i;
16411641

16421642
nft_pipapo_for_each_field(f, i, m) {
1643+
bool last = i == m->field_count - 1;
16431644
int g;
16441645

16451646
for (g = 0; g < f->groups; g++) {
@@ -1659,7 +1660,7 @@ static void pipapo_drop(struct nft_pipapo_match *m,
16591660
}
16601661

16611662
pipapo_unmap(f->mt, f->rules, rulemap[i].to, rulemap[i].n,
1662-
rulemap[i + 1].n, i == m->field_count - 1);
1663+
last ? 0 : rulemap[i + 1].n, last);
16631664
if (pipapo_resize(f, f->rules, f->rules - rulemap[i].n)) {
16641665
/* We can ignore this, a failure to shrink tables down
16651666
* doesn't make tables invalid.

net/netfilter/xt_IDLETIMER.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par)
318318

319319
info->timer = __idletimer_tg_find_by_label(info->label);
320320
if (info->timer) {
321+
if (info->timer->timer_type & XT_IDLETIMER_ALARM) {
322+
pr_debug("Adding/Replacing rule with same label and different timer type is not allowed\n");
323+
mutex_unlock(&list_mutex);
324+
return -EINVAL;
325+
}
326+
321327
info->timer->refcnt++;
322328
mod_timer(&info->timer->timer,
323329
secs_to_jiffies(info->timeout) + jiffies);

net/netfilter/xt_dccp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ dccp_find_option(u_int8_t option,
6262
return true;
6363
}
6464

65-
if (op[i] < 2)
65+
if (op[i] < 2 || i == optlen - 1)
6666
i++;
6767
else
68-
i += op[i+1]?:1;
68+
i += op[i + 1] ? : 1;
6969
}
7070

7171
spin_unlock_bh(&dccp_buflock);

net/netfilter/xt_tcpudp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ tcp_find_option(u_int8_t option,
5959

6060
for (i = 0; i < optlen; ) {
6161
if (op[i] == option) return !invert;
62-
if (op[i] < 2) i++;
63-
else i += op[i+1]?:1;
62+
if (op[i] < 2 || i == optlen - 1)
63+
i++;
64+
else
65+
i += op[i + 1] ? : 1;
6466
}
6567

6668
return invert;

0 commit comments

Comments
 (0)