* [PATCH nf] netfilter: nf_tables: fix possible oops when dumping stateful objects
@ 2017-01-07 12:51 Liping Zhang
2017-01-16 13:26 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Liping Zhang @ 2017-01-07 12:51 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, Liping Zhang
From: Liping Zhang <zlpnobody@gmail.com>
When dumping nft stateful objects, if NFTA_OBJ_TABLE and NFTA_OBJ_TYPE
attributes are not specified either, filter will become NULL, so oops
will happen(actually nft utility will always set NFTA_OBJ_TABLE attr,
so I write a test program to make this happen):
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: nf_tables_dump_obj+0x17c/0x330 [nf_tables]
[...]
Call Trace:
? nf_tables_dump_obj+0x5/0x330 [nf_tables]
? __kmalloc_reserve.isra.35+0x31/0x90
? __alloc_skb+0x5b/0x1e0
netlink_dump+0x124/0x2a0
__netlink_dump_start+0x161/0x190
nf_tables_getobj+0xe8/0x280 [nf_tables]
Fixes: a9fea2a3c3cf ("netfilter: nf_tables: allow to filter stateful object dumps by type")
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
---
net/netfilter/nf_tables_api.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 0db5f97..091d2dc 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4262,10 +4262,11 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
if (idx > s_idx)
memset(&cb->args[1], 0,
sizeof(cb->args) - sizeof(cb->args[0]));
- if (filter->table[0] &&
+ if (filter && filter->table[0] &&
strcmp(filter->table, table->name))
goto cont;
- if (filter->type != NFT_OBJECT_UNSPEC &&
+ if (filter &&
+ filter->type != NFT_OBJECT_UNSPEC &&
obj->type->type != filter->type)
goto cont;
--
2.5.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf] netfilter: nf_tables: fix possible oops when dumping stateful objects
2017-01-07 12:51 [PATCH nf] netfilter: nf_tables: fix possible oops when dumping stateful objects Liping Zhang
@ 2017-01-16 13:26 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-01-16 13:26 UTC (permalink / raw)
To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang
On Sat, Jan 07, 2017 at 08:51:50PM +0800, Liping Zhang wrote:
> From: Liping Zhang <zlpnobody@gmail.com>
>
> When dumping nft stateful objects, if NFTA_OBJ_TABLE and NFTA_OBJ_TYPE
> attributes are not specified either, filter will become NULL, so oops
> will happen(actually nft utility will always set NFTA_OBJ_TABLE attr,
> so I write a test program to make this happen):
>
> BUG: unable to handle kernel NULL pointer dereference at (null)
> IP: nf_tables_dump_obj+0x17c/0x330 [nf_tables]
> [...]
> Call Trace:
> ? nf_tables_dump_obj+0x5/0x330 [nf_tables]
> ? __kmalloc_reserve.isra.35+0x31/0x90
> ? __alloc_skb+0x5b/0x1e0
> netlink_dump+0x124/0x2a0
> __netlink_dump_start+0x161/0x190
> nf_tables_getobj+0xe8/0x280 [nf_tables]
Also applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-16 13:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-07 12:51 [PATCH nf] netfilter: nf_tables: fix possible oops when dumping stateful objects Liping Zhang
2017-01-16 13:26 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).