Blame SOURCES/CVE-2024-1086.patch

773c19
From 0b95e025ee195fd549a77916c14af38e9b25ac16 Mon Sep 17 00:00:00 2001
773c19
From: Ryan Sullivan <rysulliv@redhat.com>
773c19
Date: Tue, 16 Apr 2024 13:57:40 -0400
773c19
Subject: [KPATCH CVE-2024-1086] kpatch fixes for CVE-2024-1086
773c19
773c19
Kernels:
773c19
3.10.0-1160.102.1.el7
773c19
3.10.0-1160.105.1.el7
773c19
3.10.0-1160.108.1.el7
773c19
773c19
773c19
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/70
773c19
Approved-by: Joe Lawrence (@joe.lawrence)
773c19
Changes since last build:
773c19
[x86_64]:
773c19
nf_tables_api.o: changed function: nft_data_init
773c19
773c19
[ppc64le]:
773c19
nf_tables_api.o: changed function: nft_data_init
773c19
nf_tables_api.o: changed function: nft_del_setelem
773c19
773c19
---------------------------
773c19
773c19
Modifications: none
773c19
773c19
commit 03d2627c7d53c06b8b28f5a57eb48ddbc1829c12
773c19
Author: Florian Westphal <fwestpha@redhat.com>
773c19
Date:   Fri Feb 2 15:28:35 2024 +0100
773c19
773c19
    netfilter: nf_tables: reject QUEUE/DROP verdict parameters
773c19
773c19
    JIRA: https://issues.redhat.com/browse/RHEL-23500
773c19
    Upstream Status: commit f342de4e2f33
773c19
    CVE: CVE-2024-1086
773c19
773c19
    commit f342de4e2f33e0e39165d8639387aa6c19dff660
773c19
    Author: Florian Westphal <fw@strlen.de>
773c19
    Date:   Sat Jan 20 22:50:04 2024 +0100
773c19
773c19
        netfilter: nf_tables: reject QUEUE/DROP verdict parameters
773c19
773c19
        This reverts commit e0abdadcc6e1.
773c19
773c19
        core.c:nf_hook_slow assumes that the upper 16 bits of NF_DROP
773c19
        verdicts contain a valid errno, i.e. -EPERM, -EHOSTUNREACH or similar,
773c19
        or 0.
773c19
773c19
        Due to the reverted commit, its possible to provide a positive
773c19
        value, e.g. NF_ACCEPT (1), which results in use-after-free.
773c19
773c19
        Its not clear to me why this commit was made.
773c19
773c19
        NF_QUEUE is not used by nftables; "queue" rules in nftables
773c19
        will result in use of "nft_queue" expression.
773c19
773c19
        If we later need to allow specifiying errno values from userspace
773c19
        (do not know why), this has to call NF_DROP_GETERR and check that
773c19
        "err <= 0" holds true.
773c19
773c19
        Fixes: e0abdadcc6e1 ("netfilter: nf_tables: accept QUEUE/DROP verdict parameters")
773c19
        Cc: stable@vger.kernel.org
773c19
        Reported-by: Notselwyn <notselwyn@pwning.tech>
773c19
        Signed-off-by: Florian Westphal <fw@strlen.de>
773c19
        Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
773c19
773c19
    Signed-off-by: Florian Westphal <fwestpha@redhat.com>
773c19
773c19
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
773c19
---
773c19
 net/netfilter/nf_tables_api.c | 16 ++++++----------
773c19
 1 file changed, 6 insertions(+), 10 deletions(-)
773c19
773c19
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
773c19
index ed8a787ac400..940f947b5fe7 100644
773c19
--- a/net/netfilter/nf_tables_api.c
773c19
+++ b/net/netfilter/nf_tables_api.c
773c19
@@ -4629,16 +4629,10 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
773c19
 	data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
773c19
 
773c19
 	switch (data->verdict.code) {
773c19
-	default:
773c19
-		switch (data->verdict.code & NF_VERDICT_MASK) {
773c19
-		case NF_ACCEPT:
773c19
-		case NF_DROP:
773c19
-		case NF_QUEUE:
773c19
-			break;
773c19
-		default:
773c19
-			return -EINVAL;
773c19
-		}
773c19
-		/* fall through */
773c19
+	case NF_ACCEPT:
773c19
+	case NF_DROP:
773c19
+	case NF_QUEUE:
773c19
+		break;
773c19
 	case NFT_CONTINUE:
773c19
 	case NFT_BREAK:
773c19
 	case NFT_RETURN:
773c19
@@ -4657,6 +4651,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
773c19
 		chain->use++;
773c19
 		data->verdict.chain = chain;
773c19
 		break;
773c19
+	default:
773c19
+		return -EINVAL;
773c19
 	}
773c19
 
773c19
 	desc->len = sizeof(data->verdict);
773c19
-- 
773c19
2.45.1
773c19
773c19