bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Paul Chaignon <paul.chaignon@orange.com>
Cc: Yonghong Song <yhs@fb.com>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	xiao.han@orange.com, paul.chaignon@gmail.com,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>
Subject: Re: [PATCH bpf-next 0/2] bpf: remove incorrect 'verifier bug' warning
Date: Tue, 26 Mar 2019 13:07:15 -0700	[thread overview]
Message-ID: <20190326200713.jl4vqtidjckyaypm@ast-mbp> (raw)
In-Reply-To: <20190321093304.GA1001@Nover>

On Thu, Mar 21, 2019 at 10:33:06AM +0100, Paul Chaignon wrote:
> On Wed, Mar 20, 2019 at 11:31PM, Yonghong Song wrote:
> > On 3/20/19 5:57 AM, Paul Chaignon wrote:
> > > The BPF verifier checks the maximum number of call stack frames twice,
> > > first in the main CFG traversal (do_check) and then in a subsequent
> > > traversal (check_max_stack_depth).  If the second check fails, it logs a
> > > 'verifier bug' warning and errors out, as the number of call stack frames
> > > should have been verified already.
> > > 
> > > However, the second check may fail without indicating a verifier bug: if
> > > the excessive function calls reside in dead code, the main CFG traversal
> > > may not visit them; the subsequent traversal visits all instructions,
> > > including dead code.
> > > 
> > > This case raises the question of how invalid dead code should be treated.
> > 
> > Maybe we should do this check after dead code elimination to be 
> > consistent with do_check? There could some other kinds of illegal stuff
> 
> To be clear, are you suggesting we run check_max_stack_depth after the
> dead code elimination?  That would indeed solve this issue, but Jakub made
> the exact reverse change not so long ago, in 9b38c40 ("bpf: verifier:
> reorder stack size check with dead code sanitization").  I think the idea
> was to avoid having code modifications in between code checks.

I think it's fine fix as it is.
I've applied it to bpf tree, since the verifier shouldn't be warning like this.

As far as changing the order back I think it's good to keep 'too many frames'
check before dead code elimination.
'too many frames' is similar to 'too many instructions'.
The verifier rejects large programs before removing dead code.
So in that sense it's similar.


      reply	other threads:[~2019-03-26 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 12:57 [PATCH bpf-next 0/2] bpf: remove incorrect 'verifier bug' warning Paul Chaignon
2019-03-20 12:58 ` [PATCH bpf-next 1/2] " Paul Chaignon
2019-03-20 12:58 ` [PATCH bpf-next 2/2] selftests/bpf: test case for invalid call stack in dead code Paul Chaignon
2019-03-20 23:31 ` [PATCH bpf-next 0/2] bpf: remove incorrect 'verifier bug' warning Yonghong Song
2019-03-21  9:33   ` Paul Chaignon
2019-03-26 20:07     ` Alexei Starovoitov [this message]

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=20190326200713.jl4vqtidjckyaypm@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.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 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).