Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ commit 5d99e198be279045e6ecefe220f5c52f8ce9bfd5 upstream.
[ Backport: 6.1 check_return_code() uses a tnum range. Add retval_range_within() as in upstream and use it for the LSM range only. Print smin/smax on failure, as upstream verbose_invalid_scalar() does. ]
[ Backport: 6.1 has no reg_bounds_sanity_check(). __mark_reg_s32_range() returns 0. ]
[ Backport: drop bpf_lsm_inode_xattr_skipcap from bool_lsm_hooks. 6.1 has no such hook. ]
[ Backport: lsm_verifier_ops now uses bpf_tracing_btf_ctx_access (stable c42da1d3ba9d backport). Adapt the context. ]

A bpf prog returning a positive number attached to file_alloc_security
hook makes kernel panic.
Expand Down Expand Up @@ -42,7 +43,7 @@ Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
6 files changed, 119 insertions(+), 11 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 0ce4f1eb92d1..0eee65c8952f 100644
index 2fad4aca6207f9..036733395890d9 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -739,6 +739,7 @@ struct bpf_insn_access_aux {
Expand All @@ -54,7 +55,7 @@ index 0ce4f1eb92d1..0eee65c8952f 100644

static inline void
diff --git a/include/linux/bpf_lsm.h b/include/linux/bpf_lsm.h
index e775990d6613..2a343bfb657e 100644
index e775990d66133e..2a343bfb657ecd 100644
--- a/include/linux/bpf_lsm.h
+++ b/include/linux/bpf_lsm.h
@@ -9,6 +9,7 @@
Expand Down Expand Up @@ -87,7 +88,7 @@ index e775990d6613..2a343bfb657e 100644

#endif /* _LINUX_BPF_LSM_H */
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 33b073deb8c1..31472d1a1b1c 100644
index e26c4b5382f65a..81f48fd5d99fce 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -228,6 +228,11 @@ struct bpf_reference_state {
Expand All @@ -103,7 +104,7 @@ index 33b073deb8c1..31472d1a1b1c 100644
struct bpf_reg_state regs[MAX_BPF_REG];
/* index of call instruction that called into this func */
diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index e7e195a2e5f9..53811281622d 100644
index f26faa9a35db15..dacc3f059dcc6f 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -11,7 +11,6 @@
Expand All @@ -115,8 +116,8 @@ index e7e195a2e5f9..53811281622d 100644
#include <linux/bpf_local_storage.h>
#include <linux/btf_ids.h>
@@ -384,3 +383,35 @@ const struct bpf_verifier_ops lsm_verifier_ops = {
.get_func_proto = bpf_lsm_func_proto,
.is_valid_access = btf_ctx_access,
.get_func_proto = bpf_lsm_func_proto,
.is_valid_access = bpf_tracing_btf_ctx_access,
};
+
+/* hooks return 0 or 1 */
Expand Down Expand Up @@ -151,10 +152,10 @@ index e7e195a2e5f9..53811281622d 100644
+ return 0;
+}
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 850ea69e05fd..092db7f6d5ca 100644
index c7ddd5f1f0dbc0..7da8e877376b4e 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -5427,8 +5427,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
@@ -5444,8 +5444,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,

if (arg == nr_args) {
switch (prog->expected_attach_type) {
Expand All @@ -168,10 +169,10 @@ index 850ea69e05fd..092db7f6d5ca 100644
/* When LSM programs are attached to void LSM hooks
* they use FEXIT trampolines and when attached to
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index b79581a941cd..1dc7aa00fe8c 100644
index f457baaf15cfa3..90a14c98070c2a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1666,6 +1666,25 @@ static void mark_reg_unknown(struct bpf_verifier_env *env,
@@ -1667,6 +1667,25 @@ static void mark_reg_unknown(struct bpf_verifier_env *env,
__mark_reg_unknown(env, regs + regno);
}

Expand All @@ -197,7 +198,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
static void __mark_reg_not_init(const struct bpf_verifier_env *env,
struct bpf_reg_state *reg)
{
@@ -4191,11 +4210,12 @@ static int check_packet_access(struct bpf_verifier_env *env, u32 regno, int off,
@@ -4219,11 +4238,12 @@ static int check_packet_access(struct bpf_verifier_env *env, u32 regno, int off,
/* check access to 'struct bpf_context' fields. Supports fixed offsets only */
static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off, int size,
enum bpf_access_type t, enum bpf_reg_type *reg_type,
Expand All @@ -211,15 +212,15 @@ index b79581a941cd..1dc7aa00fe8c 100644
};

if (env->ops->is_valid_access &&
@@ -4208,6 +4228,7 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off,
@@ -4236,6 +4256,7 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off,
* type of narrower access.
*/
*reg_type = info.reg_type;
+ *is_retval = info.is_retval;

if (base_type(*reg_type) == PTR_TO_BTF_ID) {
*btf = info.btf;
@@ -4939,6 +4960,17 @@ static int check_stack_access_within_bounds(
@@ -4967,6 +4988,17 @@ static int check_stack_access_within_bounds(
return grow_stack_state(env, state, round_up(-min_off, BPF_REG_SIZE));
}

Expand All @@ -237,7 +238,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
/* check whether memory at (regno + off) is accessible for t = (read | write)
* if t==write, value_regno is a register which value is stored into memory
* if t==read, value_regno is a register which will receive the value from memory
@@ -5044,6 +5076,8 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
@@ -5072,6 +5104,8 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
if (!err && value_regno >= 0 && (t == BPF_READ || rdonly_mem))
mark_reg_unknown(env, regs, value_regno);
} else if (reg->type == PTR_TO_CTX) {
Expand All @@ -246,7 +247,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
enum bpf_reg_type reg_type = SCALAR_VALUE;
struct btf *btf = NULL;
u32 btf_id = 0;
@@ -5059,7 +5093,7 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
@@ -5087,7 +5121,7 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
return err;

err = check_ctx_access(env, insn_idx, off, size, t, &reg_type, &btf,
Expand All @@ -255,7 +256,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
if (err)
verbose_linfo(env, insn_idx, "; ");
if (!err && t == BPF_READ && value_regno >= 0) {
@@ -5068,7 +5102,14 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
@@ -5096,7 +5130,14 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
* case, we know the offset is zero.
*/
if (reg_type == SCALAR_VALUE) {
Expand All @@ -271,7 +272,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
} else {
mark_reg_known_zero(env, regs,
value_regno);
@@ -10794,9 +10835,16 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
@@ -10858,9 +10899,16 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
return 0;
}

Expand All @@ -288,7 +289,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
const struct bpf_prog *prog = env->prog;
struct bpf_reg_state *reg;
struct tnum range = tnum_range(0, 1), const_0 = tnum_const(0);
@@ -10914,12 +10962,14 @@ static int check_return_code(struct bpf_verifier_env *env)
@@ -10978,12 +11026,14 @@ static int check_return_code(struct bpf_verifier_env *env)

case BPF_PROG_TYPE_LSM:
if (env->prog->expected_attach_type != BPF_LSM_CGROUP) {
Expand All @@ -309,7 +310,7 @@ index b79581a941cd..1dc7aa00fe8c 100644
/* Make sure programs that attach to void
* hooks don't try to modify return value.
*/
@@ -10941,6 +10991,16 @@ static int check_return_code(struct bpf_verifier_env *env)
@@ -11005,6 +11055,16 @@ static int check_return_code(struct bpf_verifier_env *env)
return -EINVAL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 1dc7aa00fe8c..f825dc4b99b4 100644
index 90a14c98070c2a..d9dd1ff86a9953 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -10835,9 +10835,13 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
@@ -10899,9 +10899,13 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
return 0;
}

Expand All @@ -64,23 +64,23 @@ index 1dc7aa00fe8c..f825dc4b99b4 100644
}

static int check_return_code(struct bpf_verifier_env *env)
@@ -10845,6 +10849,7 @@ static int check_return_code(struct bpf_verifier_env *env)
@@ -10909,6 +10913,7 @@ static int check_return_code(struct bpf_verifier_env *env)
struct tnum enforce_attach_type_range = tnum_unknown;
struct bpf_retval_range retval_range;
bool use_retval_range = false;
+ bool return_32bit = false;
const struct bpf_prog *prog = env->prog;
struct bpf_reg_state *reg;
struct tnum range = tnum_range(0, 1), const_0 = tnum_const(0);
@@ -10969,6 +10974,7 @@ static int check_return_code(struct bpf_verifier_env *env)
@@ -11033,6 +11038,7 @@ static int check_return_code(struct bpf_verifier_env *env)
if (retval_range.minval == S32_MIN && retval_range.maxval == S32_MAX)
return 0;
use_retval_range = true;
+ return_32bit = true;
} else if (!env->prog->aux->attach_func_proto->type) {
/* Make sure programs that attach to void
* hooks don't try to modify return value.
@@ -10992,7 +10998,7 @@ static int check_return_code(struct bpf_verifier_env *env)
@@ -11056,7 +11062,7 @@ static int check_return_code(struct bpf_verifier_env *env)
}

if (use_retval_range) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index f825dc4b99b4..e396491dfe23 100644
index d9dd1ff86a9953..3164307f95787f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5103,6 +5103,7 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
@@ -5131,6 +5131,7 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
*/
if (reg_type == SCALAR_VALUE) {
if (is_retval && get_func_retval_range(env->prog, &range)) {
Expand Down
2 changes: 1 addition & 1 deletion cve/CVE-2024-47703/6.1/base
Original file line number Diff line number Diff line change
@@ -1 +1 @@
08889840163ebcdb7e24bf7ec311bc2e6fc3aaea
1ca1436ccc68275d0b43b6a730b3940fcc46b7c2
18 changes: 12 additions & 6 deletions cve/CVE-2024-47703/6.1/fasttrack.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"series": "6.1",
"base": {
"commit": "08889840163ebcdb7e24bf7ec311bc2e6fc3aaea",
"version": "6.1.191"
"commit": "1ca1436ccc68275d0b43b6a730b3940fcc46b7c2",
"version": "6.1.193"
},
"incident": "CVE-2024-47703",
"outcome": "patched-needs-review",
"fixed_in": null,
"made": "2026-11-01T01:07:31Z",
"made": "2026-11-29T03:55:26Z",
"patches": [
{
"series": "6.1",
Expand All @@ -24,7 +24,9 @@
"files": [],
"prerequisites": [],
"build_log": "",
"backport": ""
"backport": "",
"bug_commits": [],
"unaffected": false
},
{
"series": "6.1",
Expand All @@ -41,7 +43,9 @@
"files": [],
"prerequisites": [],
"build_log": "",
"backport": ""
"backport": "",
"bug_commits": [],
"unaffected": false
},
{
"series": "6.1",
Expand All @@ -58,7 +62,9 @@
"files": [],
"prerequisites": [],
"build_log": "",
"backport": ""
"backport": "",
"bug_commits": [],
"unaffected": false
}
]
}
2 changes: 1 addition & 1 deletion cve/CVE-2024-47703/6.1/series.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by ksec-fasttrack. Do not edit by hand: the next run rewrites it.
# Security fixes not yet in a 6.1 stable release, verified to apply as a series,
# with no fuzz, on top of 08889840163e (6.1.191).
# with no fuzz, on top of 1ca1436ccc68 (6.1.193).

0001-5d99e198be27-bpf-lsm-add-check-for-bpf-lsm-return-value.patch
0002-763aa759d3b2-bpf-fix-compare-error-in-function-retval-range-withi.patch
Expand Down
Loading