lkml.org 
[lkml]   [2021]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.13 118/156] netfilter: nf_tables: Fix dereference of null pointer flow
    Date
    From: Colin Ian King <colin.king@canonical.com>

    commit 4ca041f919f13783b0b03894783deee00dbca19a upstream.

    In the case where chain->flags & NFT_CHAIN_HW_OFFLOAD is false then
    nft_flow_rule_create is not called and flow is NULL. The subsequent
    error handling execution via label err_destroy_flow_rule will lead
    to a null pointer dereference on flow when calling nft_flow_rule_destroy.
    Since the error path to err_destroy_flow_rule has to cater for null
    and non-null flows, only call nft_flow_rule_destroy if flow is non-null
    to fix this issue.

    Addresses-Coverity: ("Explicity null dereference")
    Fixes: 3c5e44622011 ("netfilter: nf_tables: memleak in hw offload abort path")
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/netfilter/nf_tables_api.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    --- a/net/netfilter/nf_tables_api.c
    +++ b/net/netfilter/nf_tables_api.c
    @@ -3453,7 +3453,8 @@ static int nf_tables_newrule(struct sk_b
    return 0;

    err_destroy_flow_rule:
    - nft_flow_rule_destroy(flow);
    + if (flow)
    + nft_flow_rule_destroy(flow);
    err_release_rule:
    nf_tables_rule_release(&ctx, rule);
    err_release_expr:

    \
     
     \ /
      Last update: 2021-07-22 19:35    [W:4.015 / U:0.352 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site