Skip to content

Commit 91d33f8

Browse files
1nzagKernel Patches Daemon
authored andcommitted
bpf: Fix off-by-one boundary validation in arena direct-value access
BPF_MAP_TYPE_ARENA accepts BPF_PSEUDO_MAP_VALUE offsets at exactly the end of the arena mapping (off == arena_size). The boundary check in arena_map_direct_value_addr() uses `>` instead of `>=`, which incorrectly allows a one-past-end pointer to be accepted. Change the condition to `>=` to correctly reject offsets that fall outside the valid arena user_vm range. Fixes: 3174603 ("bpf: Introduce bpf_arena.") Signed-off-by: Junyoung Jang <[email protected]> Reviewed-by: Emil Tsalapatis <[email protected]>
1 parent 010a7e6 commit 91d33f8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/bpf/arena.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static int arena_map_direct_value_addr(const struct bpf_map *map, u64 *imm, u32
511511
{
512512
struct bpf_arena *arena = container_of(map, struct bpf_arena, map);
513513

514-
if ((u64)off > arena->user_vm_end - arena->user_vm_start)
514+
if ((u64)off >= arena->user_vm_end - arena->user_vm_start)
515515
return -ERANGE;
516516
*imm = (unsigned long)arena->user_vm_start;
517517
return 0;

0 commit comments

Comments
 (0)