lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 26 Oct 2015 14:48:11 +0800
From:	"Wangnan (F)" <wangnan0@...wei.com>
To:	<acme@...nel.org>, <ast@...nel.org>
CC:	<linux-kernel@...r.kernel.org>, <pi3orama@....com>,
	<lizefan@...wei.com>, Arnaldo Carvalho de Melo <acme@...hat.com>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [net-next PATCH] bpf: Output error message to logbuf when loading



On 2015/10/26 14:36, Wang Nan wrote:
> Many reason can make bpf_prog_load() return EINVAL. This patch utilizes
> logbuf passed from user to deliver the actual reason of failure.
>
> Without this patch, people is easy to forget fixing the "version"
> section in their BPF objects.
>
> Signed-off-by: Wang Nan <wangnan0@...wei.com>
> Cc: Alexei Starovoitov <ast@...nel.org>
> Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> Cc: David S. Miller <davem@...emloft.net>
> ---
>   kernel/bpf/syscall.c | 41 ++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 38 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 687dd6c..3a0e4e7 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -574,6 +574,32 @@ struct bpf_prog *bpf_prog_get(u32 ufd)
>   }
>   EXPORT_SYMBOL_GPL(bpf_prog_get);
>   
> +static void
> +bpf_prog_load_note(union bpf_attr *attr, const char *fmt, ...)
> +{
> +	u32 log_level, log_size, log_len;
> +	char __user *log_ubuf = NULL;
> +	/* 64 chars should be long enough for a one line note. */
> +	char log_buf[64];
> +	va_list args;
> +
> +	log_ubuf = (char __user *) (unsigned long) attr->log_buf;
> +	log_level = attr->log_level;
> +	log_size = sizeof(log_buf);
> +	if (attr->log_size < log_size)
> +		log_size = attr->log_size;
> +
> +	if (log_level == 0 || !log_size || !log_ubuf)
> +		return;
> +
> +	va_start(args, fmt);
> +	log_len = vscnprintf(log_buf, log_size, fmt, args);

Don't need this log_len actually. Will send a v2.

Thank you.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ