From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Krister Johansen <kjlx@templeofstupid.com>
Cc: stable@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Ilya Leoshkevich <iii@linux.ibm.com>, Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH 5.15.y v2] bpf: ensure main program has an extable
Date: Thu, 29 Jun 2023 14:10:01 +0200 [thread overview]
Message-ID: <2023062954-oppressor-curled-50ed@gregkh> (raw)
In-Reply-To: <20230629013508.GF1918@templeofstupid.com>
On Wed, Jun 28, 2023 at 06:35:08PM -0700, Krister Johansen wrote:
> commit 0108a4e9f3584a7a2c026d1601b0682ff7335d95 upstream.
>
> When subprograms are in use, the main program is not jit'd after the
> subprograms because jit_subprogs sets a value for prog->bpf_func upon
> success. Subsequent calls to the JIT are bypassed when this value is
> non-NULL. This leads to a situation where the main program and its
> func[0] counterpart are both in the bpf kallsyms tree, but only func[0]
> has an extable. Extables are only created during JIT. Now there are
> two nearly identical program ksym entries in the tree, but only one has
> an extable. Depending upon how the entries are placed, there's a chance
> that a fault will call search_extable on the aux with the NULL entry.
>
> Since jit_subprogs already copies state from func[0] to the main
> program, include the extable pointer in this state duplication.
> Additionally, ensure that the copy of the main program in func[0] is not
> added to the bpf_prog_kallsyms table. Instead, let the main program get
> added later in bpf_prog_load(). This ensures there is only a single
> copy of the main program in the kallsyms table, and that its tag matches
> the tag observed by tooling like bpftool.
>
> Cc: stable@vger.kernel.org
> Fixes: 1c2a088a6626 ("bpf: x64: add JIT support for multi-function programs")
> Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
> Acked-by: Yonghong Song <yhs@fb.com>
> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
> Link: https://lore.kernel.org/r/6de9b2f4b4724ef56efbb0339daaa66c8b68b1e7.1686616663.git.kjlx@templeofstupid.com
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
> ---
> kernel/bpf/verifier.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Now queued up, thanks.
greg k-h
prev parent reply other threads:[~2023-06-29 12:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 9:46 FAILED: patch "[PATCH] bpf: ensure main program has an extable" failed to apply to 5.15-stable tree gregkh
2023-06-28 23:03 ` [PATCH 5.15.y] bpf: ensure main program has an extable Krister Johansen
2023-06-28 23:39 ` Krister Johansen
2023-06-29 1:35 ` [PATCH 5.15.y v2] " Krister Johansen
2023-06-29 12:10 ` Greg Kroah-Hartman [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=2023062954-oppressor-curled-50ed@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=ast@kernel.org \
--cc=iii@linux.ibm.com \
--cc=kjlx@templeofstupid.com \
--cc=stable@vger.kernel.org \
--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