|
|
098754 |
From 93b3d4237a6eccd92ab6cd4828541cfe512d513b Mon Sep 17 00:00:00 2001
|
|
|
098754 |
From: Julia Denham <jdenham@redhat.com>
|
|
|
098754 |
Date: Thu, 16 Jun 2022 15:36:44 -0400
|
|
|
098754 |
Subject: [KPATCH CVE-2022-1966] kpatch fixes for CVE-2022-1966
|
|
|
098754 |
Content-type: text/plain
|
|
|
098754 |
|
|
|
098754 |
Kernels:
|
|
|
098754 |
5.14.0-70.13.1.el9_0
|
|
|
098754 |
|
|
|
098754 |
Changes since last build:
|
|
|
098754 |
arches: x86_64 ppc64le
|
|
|
098754 |
nf_tables_api.o: changed function: nft_expr_init
|
|
|
098754 |
nf_tables_api.o: changed function: nft_set_elem_expr_alloc
|
|
|
098754 |
---------------------------
|
|
|
098754 |
|
|
|
098754 |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-9/-/merge_requests/3
|
|
|
098754 |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
098754 |
Modifications: none
|
|
|
098754 |
|
|
|
098754 |
commit 4dbedeaa74d57da26219448d417db8340db6d042
|
|
|
098754 |
Author: Phil Sutter <psutter@redhat.com>
|
|
|
098754 |
Date: Thu Jun 2 20:42:43 2022 +0200
|
|
|
098754 |
|
|
|
098754 |
netfilter: nf_tables: disallow non-stateful expression in sets earlier
|
|
|
098754 |
|
|
|
098754 |
Bugzilla: https://bugzilla.redhat.com/2092994
|
|
|
098754 |
CVE: CVE-2022-1966
|
|
|
098754 |
Y-Commit: b26a2ad4080a9e9b62ebf5c68024363b1561cac5
|
|
|
098754 |
|
|
|
098754 |
O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092995
|
|
|
098754 |
Upstream Status: net.git commit 520778042ccca
|
|
|
098754 |
O-CVE: CVE-2022-1966
|
|
|
098754 |
|
|
|
098754 |
commit 520778042ccca019f3ffa136dd0ca565c486cedd
|
|
|
098754 |
Author: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
098754 |
Date: Wed May 25 10:36:38 2022 +0200
|
|
|
098754 |
|
|
|
098754 |
netfilter: nf_tables: disallow non-stateful expression in sets earlier
|
|
|
098754 |
|
|
|
098754 |
Since 3e135cd499bf ("netfilter: nft_dynset: dynamic stateful expression
|
|
|
098754 |
instantiation"), it is possible to attach stateful expressions to set
|
|
|
098754 |
elements.
|
|
|
098754 |
|
|
|
098754 |
cd5125d8f518 ("netfilter: nf_tables: split set destruction in deactivate
|
|
|
098754 |
and destroy phase") introduces conditional destruction on the object to
|
|
|
098754 |
accomodate transaction semantics.
|
|
|
098754 |
|
|
|
098754 |
nft_expr_init() calls expr->ops->init() first, then check for
|
|
|
098754 |
NFT_STATEFUL_EXPR, this stills allows to initialize a non-stateful
|
|
|
098754 |
lookup expressions which points to a set, which might lead to UAF since
|
|
|
098754 |
the set is not properly detached from the set->binding for this case.
|
|
|
098754 |
Anyway, this combination is non-sense from nf_tables perspective.
|
|
|
098754 |
|
|
|
098754 |
This patch fixes this problem by checking for NFT_STATEFUL_EXPR before
|
|
|
098754 |
expr->ops->init() is called.
|
|
|
098754 |
|
|
|
098754 |
The reporter provides a KASAN splat and a poc reproducer (similar to
|
|
|
098754 |
those autogenerated by syzbot to report use-after-free errors). It is
|
|
|
098754 |
unknown to me if they are using syzbot or if they use similar automated
|
|
|
098754 |
tool to locate the bug that they are reporting.
|
|
|
098754 |
|
|
|
098754 |
For the record, this is the KASAN splat.
|
|
|
098754 |
|
|
|
098754 |
[ 85.431824] ==================================================================
|
|
|
098754 |
[ 85.432901] BUG: KASAN: use-after-free in nf_tables_bind_set+0x81b/0xa20
|
|
|
098754 |
[ 85.433825] Write of size 8 at addr ffff8880286f0e98 by task poc/776
|
|
|
098754 |
[ 85.434756]
|
|
|
098754 |
[ 85.434999] CPU: 1 PID: 776 Comm: poc Tainted: G W 5.18.0+ #2
|
|
|
098754 |
[ 85.436023] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
|
|
|
098754 |
|
|
|
098754 |
Fixes: 0b2d8a7b638b ("netfilter: nf_tables: add helper functions for expression handling")
|
|
|
098754 |
Reported-and-tested-by: Aaron Adams <edg-e@nccgroup.com>
|
|
|
098754 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
098754 |
|
|
|
098754 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
098754 |
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
|
|
|
098754 |
|
|
|
098754 |
Signed-off-by: Julia Denham <jdenham@redhat.com>
|
|
|
098754 |
---
|
|
|
098754 |
net/netfilter/nf_tables_api.c | 19 ++++++++++---------
|
|
|
098754 |
1 file changed, 10 insertions(+), 9 deletions(-)
|
|
|
098754 |
|
|
|
098754 |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
|
|
|
098754 |
index a3116d96ac88..d495e10044dc 100644
|
|
|
098754 |
--- a/net/netfilter/nf_tables_api.c
|
|
|
098754 |
+++ b/net/netfilter/nf_tables_api.c
|
|
|
098754 |
@@ -2778,27 +2778,31 @@ static struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
|
|
|
098754 |
|
|
|
098754 |
err = nf_tables_expr_parse(ctx, nla, &expr_info);
|
|
|
098754 |
if (err < 0)
|
|
|
098754 |
- goto err1;
|
|
|
098754 |
+ goto err_expr_parse;
|
|
|
098754 |
+
|
|
|
098754 |
+ err = -EOPNOTSUPP;
|
|
|
098754 |
+ if (!(expr_info.ops->type->flags & NFT_EXPR_STATEFUL))
|
|
|
098754 |
+ goto err_expr_stateful;
|
|
|
098754 |
|
|
|
098754 |
err = -ENOMEM;
|
|
|
098754 |
expr = kzalloc(expr_info.ops->size, GFP_KERNEL);
|
|
|
098754 |
if (expr == NULL)
|
|
|
098754 |
- goto err2;
|
|
|
098754 |
+ goto err_expr_stateful;
|
|
|
098754 |
|
|
|
098754 |
err = nf_tables_newexpr(ctx, &expr_info, expr);
|
|
|
098754 |
if (err < 0)
|
|
|
098754 |
- goto err3;
|
|
|
098754 |
+ goto err_expr_new;
|
|
|
098754 |
|
|
|
098754 |
return expr;
|
|
|
098754 |
-err3:
|
|
|
098754 |
+err_expr_new:
|
|
|
098754 |
kfree(expr);
|
|
|
098754 |
-err2:
|
|
|
098754 |
+err_expr_stateful:
|
|
|
098754 |
owner = expr_info.ops->type->owner;
|
|
|
098754 |
if (expr_info.ops->type->release_ops)
|
|
|
098754 |
expr_info.ops->type->release_ops(expr_info.ops);
|
|
|
098754 |
|
|
|
098754 |
module_put(owner);
|
|
|
098754 |
-err1:
|
|
|
098754 |
+err_expr_parse:
|
|
|
098754 |
return ERR_PTR(err);
|
|
|
098754 |
}
|
|
|
098754 |
|
|
|
098754 |
@@ -5318,9 +5322,6 @@ struct nft_expr *nft_set_elem_expr_alloc(const struct nft_ctx *ctx,
|
|
|
098754 |
return expr;
|
|
|
098754 |
|
|
|
098754 |
err = -EOPNOTSUPP;
|
|
|
098754 |
- if (!(expr->ops->type->flags & NFT_EXPR_STATEFUL))
|
|
|
098754 |
- goto err_set_elem_expr;
|
|
|
098754 |
-
|
|
|
098754 |
if (expr->ops->type->flags & NFT_EXPR_GC) {
|
|
|
098754 |
if (set->flags & NFT_SET_TIMEOUT)
|
|
|
098754 |
goto err_set_elem_expr;
|
|
|
098754 |
--
|
|
|
098754 |
2.26.3
|
|
|
098754 |
|
|
|
098754 |
|