bpf: also show process name/pid in bpf_jit_dump
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 30 Jul 2015 10:42:49 +0000 (12:42 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Jul 2015 18:13:21 +0000 (11:13 -0700)
It can be useful for testing to see the actual process/pid who is loading
a given filter. I was running some BPF test program and noticed unusual
filter loads from time to time, triggered by some other application in the
background. bpf_jit_disasm is still working after this change.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/filter.h

index 6b025491120d17e5a3bb676712100dc091e8a8de..fa2cab985e577681c801f8861c299ad938ec9ffc 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/linkage.h>
 #include <linux/printk.h>
 #include <linux/workqueue.h>
+#include <linux/sched.h>
 
 #include <asm/cacheflush.h>
 
@@ -438,8 +439,9 @@ void bpf_jit_free(struct bpf_prog *fp);
 static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
                                u32 pass, void *image)
 {
-       pr_err("flen=%u proglen=%u pass=%u image=%pK\n",
-              flen, proglen, pass, image);
+       pr_err("flen=%u proglen=%u pass=%u image=%pK from=%s pid=%d\n", flen,
+              proglen, pass, image, current->comm, task_pid_nr(current));
+
        if (image)
                print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
                               16, 1, image, proglen, false);