From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Kees Cook <keescook@chromium.org>
Cc: 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 06:54:54 +0200 [thread overview]
Message-ID: <YI+CHjLBg/ob6ei4@kroah.com> (raw)
In-Reply-To: <20210502172326.2060025-1-keescook@chromium.org>
On Sun, May 02, 2021 at 10:23:26AM -0700, 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>
> ---
> drivers/acpi/custom_method.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
> index 7b54dc95d36b..36d95a02cd30 100644
> --- a/drivers/acpi/custom_method.c
> +++ b/drivers/acpi/custom_method.c
> @@ -53,10 +53,8 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
> if ((*ppos > max_size) ||
> (*ppos + count > max_size) ||
> (*ppos + count < count) ||
> - (count > uncopied_bytes)) {
> - kfree(buf);
> + (count > uncopied_bytes))
> return -EINVAL;
> - }
>
> if (copy_from_user(buf + (*ppos), user_buf, count)) {
> kfree(buf);
> @@ -76,7 +74,6 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
> add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
> }
>
> - kfree(buf);
> return count;
> }
>
> --
> 2.25.1
>
Thanks for the revert, I'll queue it up on my larger "umn.edu reverts"
branch that I'll be sending out for review in a day or so.
greg k-h
next prev parent reply other threads:[~2021-05-03 4:55 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 [this message]
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
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=YI+CHjLBg/ob6ei4@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=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 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.