This is a note to let you know that I've just added the patch titled netfilter: nf_tables: typo NULL check in _clone() function to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: netfilter-nf_tables-typo-null-check-in-_clone-function.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 51edb2ff1c6fc27d3fa73f0773a31597ecd8e230 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> Date: Mon, 10 Jan 2022 20:48:17 +0100 Subject: netfilter: nf_tables: typo NULL check in _clone() function From: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> commit 51edb2ff1c6fc27d3fa73f0773a31597ecd8e230 upstream. This should check for NULL in case memory allocation fails. Reported-by: Julian Wiedmann <jwiedmann.dev@xxxxxxxxx> Fixes: 3b9e2ea6c11b ("netfilter: nft_limit: move stateful fields out of expression data") Fixes: 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data") Fixes: 33a24de37e81 ("netfilter: nft_last: move stateful fields out of expression data") Fixes: ed0a0c60f0e5 ("netfilter: nft_quota: move stateful fields out of expression data") Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20220110194817.53481-1-pablo@xxxxxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/netfilter/nft_connlimit.c | 2 +- net/netfilter/nft_last.c | 2 +- net/netfilter/nft_limit.c | 2 +- net/netfilter/nft_quota.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) --- a/net/netfilter/nft_connlimit.c +++ b/net/netfilter/nft_connlimit.c @@ -206,7 +206,7 @@ static int nft_connlimit_clone(struct nf struct nft_connlimit *priv_src = nft_expr_priv(src); priv_dst->list = kmalloc(sizeof(*priv_dst->list), GFP_ATOMIC); - if (priv_dst->list) + if (!priv_dst->list) return -ENOMEM; nf_conncount_list_init(priv_dst->list); --- a/net/netfilter/nft_last.c +++ b/net/netfilter/nft_last.c @@ -106,7 +106,7 @@ static int nft_last_clone(struct nft_exp struct nft_last_priv *priv_dst = nft_expr_priv(dst); priv_dst->last = kzalloc(sizeof(*priv_dst->last), GFP_ATOMIC); - if (priv_dst->last) + if (!priv_dst->last) return -ENOMEM; return 0; --- a/net/netfilter/nft_limit.c +++ b/net/netfilter/nft_limit.c @@ -150,7 +150,7 @@ static int nft_limit_clone(struct nft_li priv_dst->invert = priv_src->invert; priv_dst->limit = kmalloc(sizeof(*priv_dst->limit), GFP_ATOMIC); - if (priv_dst->limit) + if (!priv_dst->limit) return -ENOMEM; spin_lock_init(&priv_dst->limit->lock); --- a/net/netfilter/nft_quota.c +++ b/net/netfilter/nft_quota.c @@ -237,7 +237,7 @@ static int nft_quota_clone(struct nft_ex struct nft_quota *priv_dst = nft_expr_priv(dst); priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), GFP_ATOMIC); - if (priv_dst->consumed) + if (!priv_dst->consumed) return -ENOMEM; atomic64_set(priv_dst->consumed, 0); Patches currently in stable-queue which might be from pablo@xxxxxxxxxxxxx are queue-5.15/netfilter-nf_tables-check-if-catch-all-set-element-is-active-in-next-generation.patch queue-5.15/netfilter-nft_quota-move-stateful-fields-out-of-expr.patch queue-5.15/ipvs-avoid-stat-macros-calls-from-preemptible-contex.patch queue-5.15/netfilter-nf_tables-skip-dead-set-elements-in-netlin.patch queue-5.15/netfilter-nft_last-copy-content-when-cloning-expression.patch queue-5.15/netfilter-nft_limit-move-stateful-fields-out-of-expr.patch queue-5.15/netfilter-nft_connlimit-memleak-if-nf_ct_netns_get-fails.patch queue-5.15/netfilter-nft_connlimit-move-stateful-fields-out-of-.patch queue-5.15/netfilter-nft_limit-fix-stateful-object-memory-leak.patch queue-5.15/netfilter-nf_tables-memcg-accounting-for-dynamically.patch queue-5.15/netfilter-nf_tables-reject-invalid-set-policy.patch queue-5.15/netfilter-nf_tables-do-not-allow-mismatch-field-size.patch queue-5.15/netfilter-nft_last-move-stateful-fields-out-of-expre.patch queue-5.15/netfilter-nft_quota-copy-content-when-cloning-expression.patch queue-5.15/netfilter-nft_limit-clone-packet-limits-cost-value.patch queue-5.15/netfilter-nf_tables-mark-newset-as-dead-on-transacti.patch queue-5.15/netfilter-nf_tables-typo-null-check-in-_clone-function.patch queue-5.15/netfilter-nft_limit-rename-stateful-structure.patch queue-5.15/netfilter-nf_tables-reject-nft_set_concat-with-not-f.patch queue-5.15/netfilter-nft_limit-do-not-ignore-unsupported-flags.patch