All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Pu Lehui <pulehui@huawei.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	syzbot+f264bffdfbd5614f3bb2@syzkaller.appspotmail.com,
	Andrii Nakryiko <andrii@kernel.org>,
	Tadeusz Struk <tadeusz.struk@linaro.org>
Subject: Re: [PATCH 5.10] bpf: Fix KASAN use-after-free Read in compute_effective_progs
Date: Tue, 23 Aug 2022 09:25:31 +0200	[thread overview]
Message-ID: <YwSA65p3f8kV8TEM@kroah.com> (raw)
In-Reply-To: <20220820050518.2118130-1-pulehui@huawei.com>

On Sat, Aug 20, 2022 at 01:05:18PM +0800, Pu Lehui wrote:
> From: Tadeusz Struk <tadeusz.struk@linaro.org>
> 
> commit 4c46091ee985ae84c60c5e95055d779fcd291d87 upstream.
> 
> Syzbot found a Use After Free bug in compute_effective_progs().
> The reproducer creates a number of BPF links, and causes a fault
> injected alloc to fail, while calling bpf_link_detach on them.
> Link detach triggers the link to be freed by bpf_link_free(),
> which calls __cgroup_bpf_detach() and update_effective_progs().
> If the memory allocation in this function fails, the function restores
> the pointer to the bpf_cgroup_link on the cgroup list, but the memory
> gets freed just after it returns. After this, every subsequent call to
> update_effective_progs() causes this already deallocated pointer to be
> dereferenced in prog_list_length(), and triggers KASAN UAF error.
> 
> To fix this issue don't preserve the pointer to the prog or link in the
> list, but remove it and replace it with a dummy prog without shrinking
> the table. The subsequent call to __cgroup_bpf_detach() or
> __cgroup_bpf_detach() will correct it.
> 
> Fixes: af6eea57437a ("bpf: Implement bpf_link-based cgroup BPF program attachment")
> Reported-by: <syzbot+f264bffdfbd5614f3bb2@syzkaller.appspotmail.com>
> Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> Cc: <stable@vger.kernel.org>
> Link: https://syzkaller.appspot.com/bug?id=8ebf179a95c2a2670f7cf1ba62429ec044369db4
> Link: https://lore.kernel.org/bpf/20220517180420.87954-1-tadeusz.struk@linaro.org
> Signed-off-by: Pu Lehui <pulehui@huawei.com>
> ---
>  kernel/bpf/cgroup.c | 70 ++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 60 insertions(+), 10 deletions(-)

Now queued up, thanks.

greg k-h

      reply	other threads:[~2022-08-23  7:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-20  5:05 [PATCH 5.10] bpf: Fix KASAN use-after-free Read in compute_effective_progs Pu Lehui
2022-08-23  7:25 ` 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=YwSA65p3f8kV8TEM@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pulehui@huawei.com \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+f264bffdfbd5614f3bb2@syzkaller.appspotmail.com \
    --cc=tadeusz.struk@linaro.org \
    /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.