Skip to content

Commit e8dbc6b

Browse files
alyssaispcmoore
authored andcommitted
api: fix seccomp_export_bpf_mem out-of-bounds read
*len is the length of the destination buffer, but program->blks is probably not anywhere near that long. It's already been checked above that BPF_PGM_SIZE(program) is less than or equal to *len, so that's the correct value to use here to avoid either reading or writing too much. I noticed this because tests/11-basic-basic_errors started failing on musl after e797591 ("all: add seccomp_precompute() functionality"). Signed-off-by: Alyssa Ross <[email protected]> Acked-by: Tom Hromatka <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 614530b commit e8dbc6b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ API int seccomp_export_bpf_mem(const scmp_filter_ctx ctx, void *buf,
786786
if (BPF_PGM_SIZE(program) > *len)
787787
rc = _rc_filter(-ERANGE);
788788
else
789-
memcpy(buf, program->blks, *len);
789+
memcpy(buf, program->blks, BPF_PGM_SIZE(program));
790790
}
791791
*len = BPF_PGM_SIZE(program);
792792

0 commit comments

Comments
 (0)