linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei.com>
To: <acme@kernel.org>, <ast@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <pi3orama@163.com>,
	<lizefan@huawei.com>, Arnaldo Carvalho de Melo <acme@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [net-next PATCH] bpf: Output error message to logbuf when loading
Date: Mon, 26 Oct 2015 14:48:11 +0800	[thread overview]
Message-ID: <562DCCAB.5040007@huawei.com> (raw)
In-Reply-To: <1445841394-142865-1-git-send-email-wangnan0@huawei.com>



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@huawei.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: David S. Miller <davem@davemloft.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.



  reply	other threads:[~2015-10-26  6:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26  6:36 [net-next PATCH] bpf: Output error message to logbuf when loading Wang Nan
2015-10-26  6:48 ` Wangnan (F) [this message]
2015-10-26  6:50 ` kbuild test robot
2015-10-26  7:13 ` [net-next PATCHv2] bpf: Output error message to logbuf when loading failure Wang Nan
2015-10-27  3:26   ` Alexei Starovoitov
2015-10-27  3:42     ` Wangnan (F)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=562DCCAB.5040007@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=pi3orama@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).