All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tadeusz Struk <tadeusz.struk@linaro.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	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>,
	Networking <netdev@vger.kernel.org>,
	linux- stable <stable@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	syzbot+f264bffdfbd5614f3bb2@syzkaller.appspotmail.com
Subject: Re: [PATCH] bpf: Fix KASAN use-after-free Read in compute_effective_progs
Date: Wed, 13 Apr 2022 12:27:15 -0700	[thread overview]
Message-ID: <bb29d766-f837-195e-63cc-15d02f155f2c@linaro.org> (raw)
In-Reply-To: <CAEf4Bzbb+AmuABH2cw=48uuznz7bT=eEMc1V9mS3GSqgU664Tw@mail.gmail.com>

On 4/13/22 12:07, Andrii Nakryiko wrote:
>> it would be ideal if detach would never fail, but it would require some kind of
>> prealloc, on attach maybe? Another option would be to minimize the probability
> We allocate new arrays in update_effective_progs() under assumption
> that we might need to grow the array because we use
> update_effective_progs() for attachment. But for detachment we know
> that we definitely don't need to increase the size, we need to remove
> existing element only, thus shrinking the size.
> 
> Normally we'd reallocate the array to shrink it (and that's why we use
> update_effective_progs() and allocate memory), but we can also have a
> fallback path for detachment only to reuse existing effective arrays
> and just shift all the elements to the right from the element that's
> being removed. We'll leave NULL at the end, but that's much better
> than error out. Subsequent attachment or detachment will attempt to
> properly size and reallocate everything.
> 
> So I think that should be the fix, if you'd be willing to work on it.

That makes it much easier then. I will change it so that there is no
alloc needed on the detach path. Thanks for the clarification.

-- 
Thanks,
Tadeusz

  reply	other threads:[~2022-04-13 19:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 17:03 [PATCH] bpf: Fix KASAN use-after-free Read in compute_effective_progs Tadeusz Struk
2022-04-12 14:44 ` Tadeusz Struk
2022-04-13  4:34 ` Andrii Nakryiko
2022-04-13 17:28   ` Tadeusz Struk
2022-04-13 19:07     ` Andrii Nakryiko
2022-04-13 19:27       ` Tadeusz Struk [this message]
2022-04-13 19:49         ` Andrii Nakryiko
2022-04-15 14:13           ` [PATCH v2] " Tadeusz Struk
2022-04-20 17:07             ` Andrii Nakryiko
2022-05-13 18:38               ` Tadeusz Struk
2022-05-13 19:08               ` [PATCH v3] " Tadeusz Struk
2022-05-16 23:16                 ` Andrii Nakryiko
2022-05-16 23:35                   ` Tadeusz Struk
2022-05-16 23:45                     ` Andrii Nakryiko
2022-05-17 18:04                   ` [PATCH v4] " Tadeusz Struk
2022-05-23 21:36                     ` Tadeusz Struk
2022-05-23 22:47                       ` Andrii Nakryiko
2022-05-23 22:58                         ` Tadeusz Struk
2022-06-02 14:37                         ` Tadeusz Struk
2022-06-02 16:11                           ` Andrii Nakryiko
2022-06-02 16:25                             ` Tadeusz Struk
2022-06-02 16:51                               ` Tadeusz Struk

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=bb29d766-f837-195e-63cc-15d02f155f2c@linaro.org \
    --to=tadeusz.struk@linaro.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --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=stable@vger.kernel.org \
    --cc=syzbot+f264bffdfbd5614f3bb2@syzkaller.appspotmail.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 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.