|
|
4c8715 |
From e34e7e4a82e772c705bacee9ef5b63fec54e729c Mon Sep 17 00:00:00 2001
|
|
|
4c8715 |
From: Yannick Cote <ycote@redhat.com>
|
|
|
4c8715 |
Date: Tue, 29 Mar 2022 13:21:16 -0400
|
|
|
4c8715 |
Subject: [KPATCH CVE-2022-25636] netfilter: kpatch fixes for CVE-2022-25636
|
|
|
4c8715 |
|
|
|
4c8715 |
Kernels:
|
|
|
4c8715 |
4.18.0-348.el8
|
|
|
4c8715 |
4.18.0-348.2.1.el8_5
|
|
|
4c8715 |
4.18.0-348.7.1.el8_5
|
|
|
4c8715 |
4.18.0-348.12.2.el8_5
|
|
|
4c8715 |
4.18.0-348.20.1.el8_5
|
|
|
4c8715 |
|
|
|
4c8715 |
|
|
|
4c8715 |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/45
|
|
|
4c8715 |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
4c8715 |
Changes since last build:
|
|
|
4c8715 |
[x86_64]:
|
|
|
4c8715 |
cma.o: changed function: rdma_listen
|
|
|
4c8715 |
nf_tables_api.o: changed function: __nf_tables_abort
|
|
|
4c8715 |
nf_tables_api.o: changed function: __nft_release_basechain
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_commit
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_exit_net
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_newrule
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_rule_destroy
|
|
|
4c8715 |
nf_tables_api.o: changed function: nft_delrule
|
|
|
4c8715 |
nf_tables_api.o: new function: nft_rule_expr_deactivate
|
|
|
4c8715 |
nf_tables_offload.o: changed function: nft_flow_rule_create
|
|
|
4c8715 |
|
|
|
4c8715 |
[ppc64le]:
|
|
|
4c8715 |
cma.o: changed function: rdma_listen
|
|
|
4c8715 |
nf_tables_api.o: changed function: __nf_tables_abort
|
|
|
4c8715 |
nf_tables_api.o: changed function: __nft_release_basechain
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_commit
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_exit_net
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_newrule
|
|
|
4c8715 |
nf_tables_api.o: changed function: nf_tables_trans_destroy_work
|
|
|
4c8715 |
nf_tables_api.o: changed function: nft_delrule
|
|
|
4c8715 |
nf_tables_offload.o: changed function: nft_flow_rule_create
|
|
|
4c8715 |
|
|
|
4c8715 |
---------------------------
|
|
|
4c8715 |
|
|
|
4c8715 |
Modifications:
|
|
|
4c8715 |
- Simplify code to fixing the vulnerability root cause.
|
|
|
4c8715 |
- For this, replace (netfilter: nf_tables_offload: incorrect flow
|
|
|
4c8715 |
offload action array size) with localized code to make sure that
|
|
|
4c8715 |
'forward' and 'dup' rules (all types really) act as having the
|
|
|
4c8715 |
NFT_OFFLOAD_F_ACTION flag set.
|
|
|
4c8715 |
|
|
|
4c8715 |
commit 9a8d76cbd3d4321f2207bc89fdf0029fe2de3705
|
|
|
4c8715 |
Author: Florian Westphal <fwestpha@redhat.com>
|
|
|
4c8715 |
Date: Tue Feb 22 00:40:19 2022 +0100
|
|
|
4c8715 |
|
|
|
4c8715 |
netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create
|
|
|
4c8715 |
|
|
|
4c8715 |
Bugzilla: https://bugzilla.redhat.com/2056866
|
|
|
4c8715 |
Y-Commit: c8c8daf989226dca2bab98b8c408a4967e24926d
|
|
|
4c8715 |
|
|
|
4c8715 |
O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2056728
|
|
|
4c8715 |
Upstream Status: commit 31cc578ae2de
|
|
|
4c8715 |
|
|
|
4c8715 |
commit 31cc578ae2de19c748af06d859019dced68e325d
|
|
|
4c8715 |
Author: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
|
|
|
4c8715 |
Date: Tue Oct 20 13:41:36 2020 +0200
|
|
|
4c8715 |
|
|
|
4c8715 |
netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create
|
|
|
4c8715 |
|
|
|
4c8715 |
This patch fixes the issue due to:
|
|
|
4c8715 |
|
|
|
4c8715 |
BUG: KASAN: slab-out-of-bounds in nft_flow_rule_create+0x622/0x6a2
|
|
|
4c8715 |
net/netfilter/nf_tables_offload.c:40
|
|
|
4c8715 |
Read of size 8 at addr ffff888103910b58 by task syz-executor227/16244
|
|
|
4c8715 |
|
|
|
4c8715 |
The error happens when expr->ops is accessed early on before performing the boundary check and after nft_expr_next() moves the expr to go out-of-bounds.
|
|
|
4c8715 |
|
|
|
4c8715 |
This patch checks the boundary condition before expr->ops that fixes the slab-out-of-bounds Read issue.
|
|
|
4c8715 |
|
|
|
4c8715 |
Add nft_expr_more() and use it to fix this problem.
|
|
|
4c8715 |
|
|
|
4c8715 |
Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
|
|
|
4c8715 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
4c8715 |
|
|
|
4c8715 |
Signed-off-by: Florian Westphal <fwestpha@redhat.com>
|
|
|
4c8715 |
Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
|
|
|
4c8715 |
|
|
|
4c8715 |
commit bd5cf01bee78b2d9c5356021d7f9bfed8d0cbe27
|
|
|
4c8715 |
Author: Florian Westphal <fwestpha@redhat.com>
|
|
|
4c8715 |
Date: Tue Feb 22 00:40:20 2022 +0100
|
|
|
4c8715 |
|
|
|
4c8715 |
netfilter: nf_tables_offload: incorrect flow offload action array size
|
|
|
4c8715 |
|
|
|
4c8715 |
Bugzilla: https://bugzilla.redhat.com/2056866
|
|
|
4c8715 |
CVE: CVE-2022-25636
|
|
|
4c8715 |
Y-Commit: fa41e65b922a9f624d51fdd9f698c096e340a6b7
|
|
|
4c8715 |
|
|
|
4c8715 |
O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2056728
|
|
|
4c8715 |
O-CVE: CVE-2022-25636
|
|
|
4c8715 |
Upstream Status: nf.git commit b1a5983f56e3
|
|
|
4c8715 |
|
|
|
4c8715 |
Conflicts:
|
|
|
4c8715 |
include/net/netfilter/nf_tables.h
|
|
|
4c8715 |
|
|
|
4c8715 |
Context only, RHEL8 lacks the offload_stats callback.
|
|
|
4c8715 |
|
|
|
4c8715 |
commit b1a5983f56e371046dcf164f90bfaf704d2b89f6
|
|
|
4c8715 |
Author: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
4c8715 |
Date: Thu Feb 17 23:41:20 2022 +0100
|
|
|
4c8715 |
|
|
|
4c8715 |
netfilter: nf_tables_offload: incorrect flow offload action array size
|
|
|
4c8715 |
|
|
|
4c8715 |
immediate verdict expression needs to allocate one slot in the flow offload
|
|
|
4c8715 |
action array, however, immediate data expression does not need to do so.
|
|
|
4c8715 |
|
|
|
4c8715 |
fwd and dup expression need to allocate one slot, this is missing.
|
|
|
4c8715 |
|
|
|
4c8715 |
Add a new offload_action interface to report if this expression needs to
|
|
|
4c8715 |
allocate one slot in the flow offload action array.
|
|
|
4c8715 |
|
|
|
4c8715 |
Fixes: be2861dc36d7 ("netfilter: nft_{fwd,dup}_netdev: add offload support")
|
|
|
4c8715 |
Reported-and-tested-by: Nick Gregory <Nick.Gregory@Sophos.com>
|
|
|
4c8715 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
4c8715 |
|
|
|
4c8715 |
Signed-off-by: Florian Westphal <fwestpha@redhat.com>
|
|
|
4c8715 |
Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
|
|
|
4c8715 |
|
|
|
4c8715 |
Signed-off-by: Yannick Cote <ycote@redhat.com>
|
|
|
4c8715 |
---
|
|
|
4c8715 |
include/net/netfilter/nf_tables.h | 6 ++++++
|
|
|
4c8715 |
net/netfilter/nf_tables_api.c | 6 +++---
|
|
|
4c8715 |
net/netfilter/nf_tables_offload.c | 6 +++---
|
|
|
4c8715 |
3 files changed, 12 insertions(+), 6 deletions(-)
|
|
|
4c8715 |
|
|
|
4c8715 |
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
|
|
|
4c8715 |
index aa5b025771b4..2f6d9959d695 100644
|
|
|
4c8715 |
--- a/include/net/netfilter/nf_tables.h
|
|
|
4c8715 |
+++ b/include/net/netfilter/nf_tables.h
|
|
|
4c8715 |
@@ -896,6 +896,12 @@ static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule)
|
|
|
4c8715 |
return (struct nft_expr *)&rule->data[rule->dlen];
|
|
|
4c8715 |
}
|
|
|
4c8715 |
|
|
|
4c8715 |
+static inline bool nft_expr_more(const struct nft_rule *rule,
|
|
|
4c8715 |
+ const struct nft_expr *expr)
|
|
|
4c8715 |
+{
|
|
|
4c8715 |
+ return expr != nft_expr_last(rule) && expr->ops;
|
|
|
4c8715 |
+}
|
|
|
4c8715 |
+
|
|
|
4c8715 |
static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)
|
|
|
4c8715 |
{
|
|
|
4c8715 |
return (void *)&rule->data[rule->dlen];
|
|
|
4c8715 |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
|
|
|
4c8715 |
index 353201d81205..9620daa81a15 100644
|
|
|
4c8715 |
--- a/net/netfilter/nf_tables_api.c
|
|
|
4c8715 |
+++ b/net/netfilter/nf_tables_api.c
|
|
|
4c8715 |
@@ -335,7 +335,7 @@ static void nft_rule_expr_activate(const struct nft_ctx *ctx,
|
|
|
4c8715 |
struct nft_expr *expr;
|
|
|
4c8715 |
|
|
|
4c8715 |
expr = nft_expr_first(rule);
|
|
|
4c8715 |
- while (expr != nft_expr_last(rule) && expr->ops) {
|
|
|
4c8715 |
+ while (nft_expr_more(rule, expr)) {
|
|
|
4c8715 |
if (expr->ops->activate)
|
|
|
4c8715 |
expr->ops->activate(ctx, expr);
|
|
|
4c8715 |
|
|
|
4c8715 |
@@ -350,7 +350,7 @@ static void nft_rule_expr_deactivate(const struct nft_ctx *ctx,
|
|
|
4c8715 |
struct nft_expr *expr;
|
|
|
4c8715 |
|
|
|
4c8715 |
expr = nft_expr_first(rule);
|
|
|
4c8715 |
- while (expr != nft_expr_last(rule) && expr->ops) {
|
|
|
4c8715 |
+ while (nft_expr_more(rule, expr)) {
|
|
|
4c8715 |
if (expr->ops->deactivate)
|
|
|
4c8715 |
expr->ops->deactivate(ctx, expr, phase);
|
|
|
4c8715 |
|
|
|
4c8715 |
@@ -2951,7 +2951,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
|
|
|
4c8715 |
* is called on error from nf_tables_newrule().
|
|
|
4c8715 |
*/
|
|
|
4c8715 |
expr = nft_expr_first(rule);
|
|
|
4c8715 |
- while (expr != nft_expr_last(rule) && expr->ops) {
|
|
|
4c8715 |
+ while (nft_expr_more(rule, expr)) {
|
|
|
4c8715 |
next = nft_expr_next(expr);
|
|
|
4c8715 |
nf_tables_expr_destroy(ctx, expr);
|
|
|
4c8715 |
expr = next;
|
|
|
4c8715 |
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
|
|
|
4c8715 |
index 499e5c51da22..091640fcc2f6 100644
|
|
|
4c8715 |
--- a/net/netfilter/nf_tables_offload.c
|
|
|
4c8715 |
+++ b/net/netfilter/nf_tables_offload.c
|
|
|
4c8715 |
@@ -93,8 +93,8 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,
|
|
|
4c8715 |
struct nft_expr *expr;
|
|
|
4c8715 |
|
|
|
4c8715 |
expr = nft_expr_first(rule);
|
|
|
4c8715 |
- while (expr->ops && expr != nft_expr_last(rule)) {
|
|
|
4c8715 |
- if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION)
|
|
|
4c8715 |
+ while (nft_expr_more(rule, expr)) {
|
|
|
4c8715 |
+ if (expr->ops->offload)
|
|
|
4c8715 |
num_actions++;
|
|
|
4c8715 |
|
|
|
4c8715 |
expr = nft_expr_next(expr);
|
|
|
4c8715 |
@@ -117,7 +117,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,
|
|
|
4c8715 |
ctx->net = net;
|
|
|
4c8715 |
ctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC;
|
|
|
4c8715 |
|
|
|
4c8715 |
- while (expr->ops && expr != nft_expr_last(rule)) {
|
|
|
4c8715 |
+ while (nft_expr_more(rule, expr)) {
|
|
|
4c8715 |
if (!expr->ops->offload) {
|
|
|
4c8715 |
err = -EOPNOTSUPP;
|
|
|
4c8715 |
goto err_out;
|
|
|
4c8715 |
--
|
|
|
4c8715 |
2.34.1
|
|
|
4c8715 |
|
|
|
4c8715 |
|