Skip to contentSkip to conversation

netfilter: nf_tables: fix possible null-pointer dereference in object update

PATCH Superseded Fernando Fernandez Mancera 3 participants 4 messages Sep 3, 2019 – Sep 4, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_tables: fix possible null-pointer dereference in object update

Fixes d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation")
---
 net/netfilter/nf_tables_api.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +2 -1
index cf767bc58e18..6893de9e1389 100644
@@ -6477,7 +6477,8 @@ static void nft_obj_commit_update(struct nft_trans *trans)
 	obj = nft_trans_obj(trans);
 	newobj = nft_trans_obj_newobj(trans);
 
-	obj->ops->update(obj, newobj);
+	if (obj->ops->update)
+		obj->ops->update(obj, newobj);
 
 	kfree(newobj);
 }
Signature · 1 line
2.20.1
reviewer
#1 lore raw

Hi Fernando,

Quoted 2 lines · Fernando Fernandez Mancera
Fixes d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation")

Your patch looks good but please (always) provide a bit of explanation. In this case typical questions to answer in commit message are:
- Why may obj->ops->update be NULL? For which object type are they not defined?
- How could one trigger the issue? In other words, why is nft_obj_commit_update() called for the "wrong" object?

Cheers, Phil

#2 lore raw

Hi Phil,

I am sending a v2 with an explanation. Thanks!

Quoted 15 lines · Phil Sutter

Hi Fernando,

Quoted 2 lines · Fernando Fernandez Mancera
Fixes d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation")

Your patch looks good but please (always) provide a bit of explanation. In this case typical questions to answer in commit message are:
- Why may obj->ops->update be NULL? For which object type are they not defined?
- How could one trigger the issue? In other words, why is nft_obj_commit_update() called for the "wrong" object?

Cheers, Phil

#3 lore raw
In reply to Fernando Fernandez Mancera
Quoted 11 lines · Fernando Fernandez Mancera
Fixes d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation")
---
 net/netfilter/nf_tables_api.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +0 -0
index cf767bc58e18..6893de9e1389 100644

net/netfilter/nf_tables_api.c static void nft_obj_commit_update(struct nft_trans *trans) · line 6481

Quoted 6 lines
net/netfilter/nf_tables_api.c +2 -1
@@ -6477,7 +6477,8 @@ static void nft_obj_commit_update(struct nft_trans *trans)
 	obj = nft_trans_obj(trans);
 	newobj = nft_trans_obj_newobj(trans);
 
-	obj->ops->update(obj, newobj);
+	if (obj->ops->update)
+		obj->ops->update(obj, newobj);

Please, check for obj->ops->update() from the preparation phase, ie. from nf_tables_updobj().

If obj->ops->update is NULL, then return -EOPNOTSUPP.