From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dongliang Mu <dzm91@hust.edu.cn>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
syzkaller <syzkaller@googlegroups.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bpf: cgroup: remove WARN_ON at bpf_cgroup_link_release
Date: Wed, 2 Mar 2022 13:46:04 +0800 [thread overview]
Message-ID: <CAD-N9QUptT_h4FtjPTNyc72jrUHW0R_-Ggf3R1V3Fsz4hoyuAw@mail.gmail.com> (raw)
In-Reply-To: <d4bed569-d448-8b59-0774-c036e4c9abe9@iogearbox.net>
On Wed, Mar 2, 2022 at 12:28 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 2/27/22 2:40 PM, Dongliang Mu wrote:
> > From: Dongliang Mu <mudongliangabcd@gmail.com>
> >
> > When syzkaller injects fault into memory allocation at
> > bpf_prog_array_alloc, the kernel encounters a memory failure and
> > returns non-zero, thus leading to one WARN_ON at
> > bpf_cgroup_link_release. The stack trace is as follows:
> >
> > __kmalloc+0x7e/0x3d0
> > bpf_prog_array_alloc+0x4f/0x60
> > compute_effective_progs+0x132/0x580
> > ? __sanitizer_cov_trace_pc+0x1a/0x40
> > update_effective_progs+0x5e/0x260
> > __cgroup_bpf_detach+0x293/0x760
> > bpf_cgroup_link_release+0xad/0x400
> > bpf_link_free+0xca/0x190
> > bpf_link_put+0x161/0x1b0
> > bpf_link_release+0x33/0x40
> > __fput+0x286/0x9f0
> >
> > Fix this by removing the WARN_ON for __cgroup_bpf_detach.
> >
> > Reported-by: syzkaller <syzkaller@googlegroups.com>
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> > ---
> > kernel/bpf/cgroup.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
> > index 514b4681a90a..fdbdcee6c9fa 100644
> > --- a/kernel/bpf/cgroup.c
> > +++ b/kernel/bpf/cgroup.c
> > @@ -896,8 +896,8 @@ static void bpf_cgroup_link_release(struct bpf_link *link)
> > return;
> > }
> >
> > - WARN_ON(__cgroup_bpf_detach(cg_link->cgroup, NULL, cg_link,
> > - cg_link->type));
> > + __cgroup_bpf_detach(cg_link->cgroup, NULL, cg_link,
> > + cg_link->type);
>
> "Fixing" by removing WARN_ON is just papering over the issue which in this case as
> mentioned is allocation failure on detach/teardown when allocating and recomputing
> effective prog arrays..
Hi Daniel,
you're right. This is not a good fix, any idea to fix the underlying
bug perfectly?
>
> > cg = cg_link->cgroup;
> > cg_link->cgroup = NULL;
> >
>
prev parent reply other threads:[~2022-03-02 5:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 13:40 [PATCH] bpf: cgroup: remove WARN_ON at bpf_cgroup_link_release Dongliang Mu
2022-03-01 16:28 ` Daniel Borkmann
2022-03-02 5:46 ` Dongliang Mu [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=CAD-N9QUptT_h4FtjPTNyc72jrUHW0R_-Ggf3R1V3Fsz4hoyuAw@mail.gmail.com \
--to=mudongliangabcd@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dzm91@hust.edu.cn \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=syzkaller@googlegroups.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).