netfilter: nf_tables: fix unexpected EOPNOTSUPP error
authorFernando Fernandez Mancera <ffmancera@riseup.net>
Sat, 2 Nov 2019 20:59:44 +0000 (21:59 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 4 Nov 2019 19:58:33 +0000 (20:58 +0100)
If the object type doesn't implement an update operation and the user tries to
update it will silently ignore the update operation.

Fixes: aa4095a156b5 ("netfilter: nf_tables: fix possible null-pointer dereference in object update")
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index d481f9b..aa26841 100644 (file)
@@ -5143,9 +5143,6 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
        struct nft_trans *trans;
        int err;
 
-       if (!obj->ops->update)
-               return -EOPNOTSUPP;
-
        trans = nft_trans_alloc(ctx, NFT_MSG_NEWOBJ,
                                sizeof(struct nft_trans_obj));
        if (!trans)
@@ -6499,7 +6496,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);
 }