Skip to content

Commit 9a5f807

Browse files
q2venKernel Patches Daemon
authored andcommitted
bpf: Allow bpf_int_jit_compile() to set errno.
There are some failure paths in bpf_int_jit_compile() that are not worth triggering a warning in __bpf_prog_ret0_warn(). For example, if we fail to allocate memory in bpf_int_jit_compile(), we should propagate -ENOMEM to userspace instead of attaching __bpf_prog_ret0_warn(). Let's pass &err to bpf_int_jit_compile() to propagate errno. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
1 parent 8167332 commit 9a5f807

File tree

15 files changed

+32
-21
lines changed

15 files changed

+32
-21
lines changed

arch/arc/net/bpf_jit_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ static struct bpf_prog *do_extra_pass(struct bpf_prog *prog)
14111411
* (re)locations involved that their addresses are not known
14121412
* during the first run.
14131413
*/
1414-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1414+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
14151415
{
14161416
vm_dump(prog);
14171417

arch/arm/net/bpf_jit_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ bool bpf_jit_needs_zext(void)
21422142
return true;
21432143
}
21442144

2145-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
2145+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
21462146
{
21472147
struct bpf_prog *tmp, *orig_prog = prog;
21482148
struct bpf_binary_header *header;

arch/arm64/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ struct arm64_jit_data {
18201820
struct jit_ctx ctx;
18211821
};
18221822

1823-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1823+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
18241824
{
18251825
int image_size, prog_size, extable_size, extable_align, extable_offset;
18261826
struct bpf_prog *tmp, *orig_prog = prog;

arch/loongarch/net/bpf_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ static int validate_code(struct jit_ctx *ctx)
11861186
return 0;
11871187
}
11881188

1189-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1189+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
11901190
{
11911191
bool tmp_blinded = false, extra_pass = false;
11921192
u8 *image_ptr;

arch/mips/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ bool bpf_jit_needs_zext(void)
909909
return true;
910910
}
911911

912-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
912+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
913913
{
914914
struct bpf_prog *tmp, *orig_prog = prog;
915915
struct bpf_binary_header *header = NULL;

arch/parisc/net/bpf_jit_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool bpf_jit_needs_zext(void)
4141
return true;
4242
}
4343

44-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
44+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
4545
{
4646
unsigned int prog_size = 0, extable_size = 0;
4747
bool tmp_blinded = false, extra_pass = false;

arch/powerpc/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ bool bpf_jit_needs_zext(void)
129129
return true;
130130
}
131131

132-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
132+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp, int *err)
133133
{
134134
u32 proglen;
135135
u32 alloclen;

arch/riscv/net/bpf_jit_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool bpf_jit_needs_zext(void)
4242
return true;
4343
}
4444

45-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
45+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
4646
{
4747
unsigned int prog_size = 0, extable_size = 0;
4848
bool tmp_blinded = false, extra_pass = false;

arch/s390/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ static struct bpf_binary_header *bpf_jit_alloc(struct bpf_jit *jit,
22552255
/*
22562256
* Compile eBPF program "fp"
22572257
*/
2258-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
2258+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp, int *err)
22592259
{
22602260
u32 stack_depth = round_up(fp->aux->stack_depth, 8);
22612261
struct bpf_prog *tmp, *orig_fp = fp;

arch/sparc/net/bpf_jit_comp_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ struct sparc64_jit_data {
14771477
struct jit_ctx ctx;
14781478
};
14791479

1480-
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1480+
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog, int *err)
14811481
{
14821482
struct bpf_prog *tmp, *orig_prog = prog;
14831483
struct sparc64_jit_data *jit_data;

0 commit comments

Comments
 (0)