From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH bpf-next v2 0/2] bpf: fix NULL pointer dereference in
Date: Thu, 18 Mar 2021 20:12:31 -0700 [thread overview]
Message-ID: <20210319031231.3707705-1-yhs@fb.com> (raw)
Jiri Olsa reported a bug in
https://lore.kernel.org/bpf/CAKH8qBuXCfUz=w8L+Fj74OaUpbosO29niYwTki7e3Ag044_aww@mail.gmail.com/T
where cgroup local storage pointer may be NULL in
bpf_get_local_storage()
helper. There are two issues uncovered by this bug:
(1). kprobe or tracepoint prog incorrectly sets cgroup local storage
before prog run,
(2). due to change from preempt_disable to migrate_disable,
preemption is possible and percpu storage might be overwritten
by other tasks.
Issue (1) has been fixed and this patch set fixed issue (2).
Please see details of Patch #1 for detailed fix.
Patch #2 fixed bpf_prog_test_run to use new signature for
bpf_cgroup_storage_set().
Patch #1 can be backported to bpf tree and Patch #2 cannot due to
refactoring done in bpf-next only.
I did not put a Fix tag as I am not able to find a proper one.
The original commit which changed from preempt_disable to
migrate_disable in bpf.h is just a wrapper where migrate_disable
still calls preempt_disable. The real migrate_disable change happens
later in kernel/sched/*.
Changelogs:
v1 -> v2:
. fix compilation issues when CONFIG_CGROUPS is off or
CONFIG_CGROUP_BPF is off.
Yonghong Song (2):
bpf: fix NULL pointer dereference in bpf_get_local_storage() helper
bpf: fix bpf_cgroup_storage_set() usage in test_run
include/linux/bpf-cgroup.h | 58 ++++++++++++++++++++++++++++++++------
include/linux/bpf.h | 22 ++++++++++++---
kernel/bpf/helpers.c | 15 +++++++---
kernel/bpf/local_storage.c | 5 ++--
net/bpf/test_run.c | 6 +++-
5 files changed, 87 insertions(+), 19 deletions(-)
--
2.30.2
next reply other threads:[~2021-03-19 3:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 3:12 Yonghong Song [this message]
2021-03-19 3:12 ` [PATCH bpf-next v2 1/2] bpf: fix NULL pointer dereference in bpf_get_local_storage() helper Yonghong Song
2021-03-20 2:47 ` Alexei Starovoitov
2021-03-20 3:31 ` Yonghong Song
2021-03-19 3:12 ` [PATCH bpf-next v2 2/2] bpf: fix bpf_cgroup_storage_set() usage in test_run Yonghong Song
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=20210319031231.3707705-1-yhs@fb.com \
--to=yhs@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@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