lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YJFo3GGxaEX037V4@kroah.com>
Date:   Tue, 4 May 2021 17:31:40 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     "Rafael J. Wysocki" <rafael@...nel.org>
Cc:     Kees Cook <keescook@...omium.org>, Wenwen Wang <wenwen@...uga.edu>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Len Brown <lenb@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
        Mark Langsdorf <mlangsdo@...hat.com>
Subject: Re: [PATCH] Revert "ACPI: custom_method: fix memory leaks"

On Tue, May 04, 2021 at 04:59:40PM +0200, Rafael J. Wysocki wrote:
> On Mon, May 3, 2021 at 6:55 AM Greg Kroah-Hartman
> <gregkh@...uxfoundation.org> wrote:
> >
> > 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@...uga.edu>
> > > Signed-off-by: Kees Cook <keescook@...omium.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;
> > >  }
> > >
> > > --
> >
> > 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.
> 
> This will conflict with the material that I'm going to push on
> Thursday that includes the two commits mentioned by Mark elsewhere in
> this thread.

I'll drop this from my patch series now that you all have this covered.

thanks!

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ