From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Mark Langsdorf <mlangsdo@redhat.com>
Cc: Kees Cook <keescook@chromium.org>,
Wenwen Wang <wenwen@cs.uga.edu>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH] Revert "ACPI: custom_method: fix memory leaks"
Date: Mon, 3 May 2021 17:15:12 +0200 [thread overview]
Message-ID: <YJATgPrq2uzZlRQQ@kroah.com> (raw)
In-Reply-To: <99653e1a-97a3-b532-1775-31d8115bfc62@redhat.com>
On Mon, May 03, 2021 at 09:58:17AM -0500, Mark Langsdorf wrote:
> On 5/3/21 9:51 AM, Greg Kroah-Hartman wrote:
> > On Mon, May 03, 2021 at 08:17:14AM -0500, Mark Langsdorf wrote:
> > > In 5/2/21 12:23 PM, Kees Cook wrote:
> > > > This reverts commit 03d1571d9513369c17e6848476763ebbd10ec2cb.
> > > >
> > > > While /sys/kernel/debug/acpi/custom_method is already a privileged-only
> > > > API providing proxied arbitrary write access to kernel memory[1][2],
> > > > with existing race conditions[3] in buffer allocation and use that could
> > > > lead to memory leaks and use-after-free conditions, the above commit
> > > > appears to accidentally make the use-after-free conditions even easier
> > > > to accomplish. ("buf" is a global variable and prior kfree()s would set
> > > > buf back to NULL.)
> > > >
> > > > This entire interface needs to be reworked (if not entirely removed).
> > > >
> > > > [1] https://lore.kernel.org/lkml/20110222193250.GA23913@outflux.net/
> > > > [2] https://lore.kernel.org/lkml/201906221659.B618D83@keescook/
> > > > [3] https://lore.kernel.org/lkml/20170109231323.GA89642@beast/
> > > >
> > > > Cc: Wenwen Wang <wenwen@cs.uga.edu>
> > > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > > ---
> > > I have two patches submitted to linux-acpi to fix the most obvious bugs in
> > > the current driver. I don't think that just reverting this patch in its
> > > entirety is a good solution: it still leaves the buf allocated in -EINVAL,
> > > as well as the weird case where a not fully consumed buffer can be
> > > reallocated without being freed on a subsequent call.
> > >
> > > https://lore.kernel.org/linux-acpi/20210427185434.34885-1-mlangsdo@redhat.com/
> > >
> > > https://lore.kernel.org/linux-acpi/20210423152818.97077-1-mlangsdo@redhat.com/
> > >
> > > I support rewriting this driver in its entirety, but reverting one bad patch
> > > to leave it in a different buggy state is less than ideal.
> > It's buggy now, and root-only, so it's a low bar at the moment :)
> >
> > Do those commits really fix the issues? Is this debugfs code even
> > needed at all or can it just be dropped?
>
> One of my commits removes the kfree(buf) at the end of the function, which
> is the code that causes the use after free for short writes. The other adds
> a kfree(buf) before allocating the buffer, to make sure that the buffer is
> free before allocating it.
>
> There are other bugs in the code that neither my patches nor the revert
> address, like the total lack of protection against concurrent writes.
Why would anyone care about concurrent writes for this debugfs file?
Is that a requirement here?
thanks,
greg k-h
next prev parent reply other threads:[~2021-05-03 15:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-02 17:23 [PATCH] Revert "ACPI: custom_method: fix memory leaks" Kees Cook
2021-05-03 4:54 ` Greg Kroah-Hartman
2021-05-04 14:59 ` Rafael J. Wysocki
2021-05-04 15:31 ` Greg Kroah-Hartman
2021-05-03 13:17 ` Mark Langsdorf
2021-05-03 14:51 ` Greg Kroah-Hartman
2021-05-03 14:58 ` Mark Langsdorf
2021-05-03 15:15 ` Greg Kroah-Hartman [this message]
2021-05-04 15:06 ` Rafael J. Wysocki
2021-05-03 18:35 ` Kees Cook
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=YJATgPrq2uzZlRQQ@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlangsdo@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=wenwen@cs.uga.edu \
/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