Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1256442
| From | Alexei Starovoitov <alexei.starovoitov@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [net-next PATCHv2] bpf: Output error message to logbuf when loading failure |
| Date | 2015-10-27 04:30 +0100 |
| Message-ID | <qo37r-8tR-7@gated-at.bofh.it> (permalink) |
| References | <qnJBM-4Q3-5@gated-at.bofh.it> <qnKet-5ir-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Oct 26, 2015 at 07:13:08AM +0000, Wang Nan wrote:
> Many reasons can make bpf_prog_load() return EINVAL. This patch utilizes
> logbuf to deliver the actual reason of the failure.
>
> Without this patch, it is very easy for user to pass an object with
> "version" section not match the kernel version code, and the problem
> is hard to determine from return code (EINVAL).
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Wu Fengguang <fengguang.wu@intel.com>
NACK
for both implementation and design.
> + /* Don't need care the copying result too much */
> + WARN(copy_to_user(log_ubuf, log_buf, log_size),
> + KERN_WARNING "Failed to copy BPF error note '%s' to log buffer\n",
> + log_buf);
unprivilged user will be spamming kernel logs?!
> - if (attr->insn_cnt >= BPF_MAXINSNS)
> + if (attr->insn_cnt >= BPF_MAXINSNS) {
> + bpf_prog_load_note(attr, "Too many instructions: %d > %d\n",
> + attr->insn_cnt, BPF_MAXINSNS);
> return -EINVAL;
if user space did that, it's wrong and can detect it
on its own.
> if (type == BPF_PROG_TYPE_KPROBE &&
> - attr->kern_version != LINUX_VERSION_CODE)
> + attr->kern_version != LINUX_VERSION_CODE) {
> + bpf_prog_load_note(attr,
> + "Kernel version mismatch: 0x%x != 0x%x\n",
> + attr->kern_version, LINUX_VERSION_CODE);
> return -EINVAL;
user space (perf) could have checked that on its own
without kernel changes.
> /* find program type: socket_filter vs tracing_filter */
> err = find_prog_type(type, prog);
> - if (err < 0)
> + if (err < 0) {
> + bpf_prog_load_note(attr, "Invalid program type: %d\n", type);
> goto free_prog;
same here.
In general syscalls muxing different error conditions into EINVAL
is a kernel wide problem and should be solved for all.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[net-next PATCH] bpf: Output error message to logbuf when loading Wang Nan <wangnan0@huawei.com> - 2015-10-26 07:40 +0100
Re: [net-next PATCH] bpf: Output error message to logbuf when loading "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-26 07:50 +0100
Re: [net-next PATCH] bpf: Output error message to logbuf when loading kbuild test robot <lkp@intel.com> - 2015-10-26 08:00 +0100
[net-next PATCHv2] bpf: Output error message to logbuf when loading failure Wang Nan <wangnan0@huawei.com> - 2015-10-26 08:20 +0100
Re: [net-next PATCHv2] bpf: Output error message to logbuf when loading failure Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2015-10-27 04:30 +0100
Re: [net-next PATCHv2] bpf: Output error message to logbuf when loading failure "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-27 04:50 +0100
csiph-web