Skip to content

Commit c568503

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: x_tables: initialise match/target check parameter struct
syzbot reports following splat: BUG: KMSAN: uninit-value in ebt_stp_mt_check+0x24b/0x450 net/bridge/netfilter/ebt_stp.c:162 ebt_stp_mt_check+0x24b/0x450 net/bridge/netfilter/ebt_stp.c:162 xt_check_match+0x1438/0x1650 net/netfilter/x_tables.c:506 ebt_check_match net/bridge/netfilter/ebtables.c:372 [inline] ebt_check_entry net/bridge/netfilter/ebtables.c:702 [inline] The uninitialised access is xt_mtchk_param->nft_compat ... which should be set to 0. Fix it by zeroing the struct beforehand, same for tgchk. ip(6)tables targetinfo uses c99-style initialiser, so no change needed there. Reported-by: [email protected] Fixes: 55917a2 ("netfilter: x_tables: add context to know if extension runs from nft_compat") Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 64e6dd1 commit c568503

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

net/bridge/netfilter/ebtables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
700700
}
701701
i = 0;
702702

703+
memset(&mtpar, 0, sizeof(mtpar));
704+
memset(&tgpar, 0, sizeof(tgpar));
703705
mtpar.net = tgpar.net = net;
704706
mtpar.table = tgpar.table = name;
705707
mtpar.entryinfo = tgpar.entryinfo = e;

net/ipv4/netfilter/ip_tables.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
531531
return -ENOMEM;
532532

533533
j = 0;
534+
memset(&mtpar, 0, sizeof(mtpar));
534535
mtpar.net = net;
535536
mtpar.table = name;
536537
mtpar.entryinfo = &e->ip;

net/ipv6/netfilter/ip6_tables.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
551551
return -ENOMEM;
552552

553553
j = 0;
554+
memset(&mtpar, 0, sizeof(mtpar));
554555
mtpar.net = net;
555556
mtpar.table = name;
556557
mtpar.entryinfo = &e->ipv6;

0 commit comments

Comments
 (0)