Skip to content

Commit 951debb

Browse files
committed
Merge branch 'bpf-next'
Daniel Borkmann says: ==================== Minor BPF updates Various minor misc updates. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ce7fa78 + b13138e commit 951debb

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

arch/s390/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ static int bpf_jit_prog(struct bpf_jit *jit, struct bpf_prog *fp)
12451245
jit->lit = jit->lit_start;
12461246
jit->prg = 0;
12471247

1248-
bpf_jit_prologue(jit, fp->type == BPF_PROG_TYPE_UNSPEC);
1248+
bpf_jit_prologue(jit, bpf_prog_was_classic(fp));
12491249
for (i = 0; i < fp->len; i += insn_count) {
12501250
insn_count = bpf_jit_insn(jit, fp, i);
12511251
if (insn_count < 0)

arch/sparc/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf];
807807
}
808808

809809
if (bpf_jit_enable > 1)
810-
bpf_jit_dump(flen, proglen, pass, image);
810+
bpf_jit_dump(flen, proglen, pass + 1, image);
811811

812812
if (image) {
813813
bpf_flush_icache(image, image + proglen);

arch/x86/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
11031103
}
11041104

11051105
if (bpf_jit_enable > 1)
1106-
bpf_jit_dump(prog->len, proglen, 0, image);
1106+
bpf_jit_dump(prog->len, proglen, pass + 1, image);
11071107

11081108
if (image) {
11091109
bpf_flush_icache(header, image + proglen);

include/linux/filter.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/linkage.h>
1313
#include <linux/printk.h>
1414
#include <linux/workqueue.h>
15+
#include <linux/sched.h>
1516

1617
#include <asm/cacheflush.h>
1718

@@ -354,6 +355,16 @@ static inline unsigned int bpf_prog_size(unsigned int proglen)
354355
offsetof(struct bpf_prog, insns[proglen]));
355356
}
356357

358+
static inline bool bpf_prog_was_classic(const struct bpf_prog *prog)
359+
{
360+
/* When classic BPF programs have been loaded and the arch
361+
* does not have a classic BPF JIT (anymore), they have been
362+
* converted via bpf_migrate_filter() to eBPF and thus always
363+
* have an unspec program type.
364+
*/
365+
return prog->type == BPF_PROG_TYPE_UNSPEC;
366+
}
367+
357368
#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))
358369

359370
#ifdef CONFIG_DEBUG_SET_MODULE_RONX
@@ -428,8 +439,9 @@ void bpf_jit_free(struct bpf_prog *fp);
428439
static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
429440
u32 pass, void *image)
430441
{
431-
pr_err("flen=%u proglen=%u pass=%u image=%pK\n",
432-
flen, proglen, pass, image);
442+
pr_err("flen=%u proglen=%u pass=%u image=%pK from=%s pid=%d\n", flen,
443+
proglen, pass, image, current->comm, task_pid_nr(current));
444+
433445
if (image)
434446
print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
435447
16, 1, image, proglen, false);

lib/test_bpf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4613,6 +4613,8 @@ static struct bpf_prog *generate_filter(int which, int *err)
46134613
}
46144614

46154615
fp->len = flen;
4616+
/* Type doesn't really matter here as long as it's not unspec. */
4617+
fp->type = BPF_PROG_TYPE_SOCKET_FILTER;
46164618
memcpy(fp->insnsi, fptr, fp->len * sizeof(struct bpf_insn));
46174619

46184620
bpf_prog_select_runtime(fp);

0 commit comments

Comments
 (0)