All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Edward Cree <ecree@solarflare.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Paul Chaignon <paul.chaignon@orange.com>,
	Alexei Starovoitov <ast@kernel.org>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	Xiao Han <xiao.han@orange.com>,
	paul.chaignon@gmail.com, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH bpf] bpf: report verifier bugs as warnings
Date: Wed, 3 Apr 2019 10:30:31 -0700	[thread overview]
Message-ID: <20190403173029.lfwhblklss62yone@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <9d809442-b652-f68f-70e7-8be703c97244@solarflare.com>

On Wed, Apr 03, 2019 at 04:52:40PM +0100, Edward Cree wrote:
> On 02/04/2019 15:37, Daniel Borkmann wrote:
> > If we really want to have a kernel warn, then lets add a
> > helper macro verbose_and_warn(...) which will trigger a one-time warning, but keeps
> > the verbose log intact as well.
> +1
> 
> Any time the verifier detects that its internal invariants have been broken,
>  logging a warning is the right thing to do, just like any other part of the
>  kernel.

It's not black and white.
As I said I don't think verbose_and_warn() is necessary.

Messages like:
verbose(env, "bpf verifier is misconfigured\n");
are technically 'broken internal invariant', but it shouldn't be a warn.

Whereas this:
        if (WARN_ON(regno >= MAX_BPF_REG)) {
                verbose(env, "mark_reg_known_zero(regs, %u)\n", regno);
                /* Something bad happened, let's kill all regs */
                for (regno = 0; regno < MAX_BPF_REG; regno++)
                        __mark_reg_not_init(regs + regno);
                return;
        }
should stay as-is.
It's a warn, and verbose message, and clean of regs.
Similarly:
        if (WARN_ON_ONCE(ptr_reg)) {
                print_verifier_state(env, state);
                verbose(env, "verifier internal error: unexpected ptr_reg\n");
                return -EINVAL;
        }
is a warn and more than just a verbose message.

verbose_and_warn() doesn't fit these two practical cases of warn + verbose.
Hence I see no reason to combine warn and verbose into single helper.
They're perfectly fine being separate.


  reply	other threads:[~2019-04-03 17:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 11:58 [PATCH bpf] bpf: report verifier bugs as warnings Paul Chaignon
2019-04-02 14:37 ` Daniel Borkmann
2019-04-02 17:39   ` Alexei Starovoitov
2019-04-03 14:40     ` Paul Chaignon
2019-04-03 15:52   ` Edward Cree
2019-04-03 17:30     ` Alexei Starovoitov [this message]
2019-04-03 20:24       ` Edward Cree
2019-04-03 22:41       ` Daniel Borkmann
2019-04-04 17:45         ` Alexei Starovoitov

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=20190403173029.lfwhblklss62yone@ast-mbp.dhcp.thefacebook.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=ecree@solarflare.com \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=paul.chaignon@gmail.com \
    --cc=paul.chaignon@orange.com \
    --cc=songliubraving@fb.com \
    --cc=xiao.han@orange.com \
    --cc=yhs@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.