linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kaneda, Erik" <erik.kaneda@intel.com>
To: "Kaneda, Erik" <erik.kaneda@intel.com>,
	Lv Yunlong <lyl2019@mail.ustc.edu.cn>,
	"Moore, Robert" <robert.moore@intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	"lenb@kernel.org" <lenb@kernel.org>
Cc: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"devel@acpica.org" <devel@acpica.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ACPICA:dbnames: Fix a error free in acpi_db_walk_for_fields
Date: Wed, 5 May 2021 23:11:36 +0000	[thread overview]
Message-ID: <MWHPR11MB15993557BD12B767517A09B4F0599@MWHPR11MB1599.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MWHPR11MB15992FA009C23A74FCBFD204F05F9@MWHPR11MB1599.namprd11.prod.outlook.com>



> -----Original Message-----
> From: Kaneda, Erik <erik.kaneda@intel.com>
> Sent: Thursday, April 29, 2021 11:01 AM
> To: Lv Yunlong <lyl2019@mail.ustc.edu.cn>; Moore, Robert
> <robert.moore@intel.com>; Wysocki, Rafael J <rafael.j.wysocki@intel.com>;
> lenb@kernel.org
> Cc: linux-acpi@vger.kernel.org; devel@acpica.org; linux-
> kernel@vger.kernel.org
> Subject: RE: [PATCH] ACPICA:dbnames: Fix a error free in
> acpi_db_walk_for_fields
> 
> 
> 
> > -----Original Message-----
> > From: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> > Sent: Monday, April 26, 2021 6:42 PM
> > To: Moore, Robert <robert.moore@intel.com>; Kaneda, Erik
> > <erik.kaneda@intel.com>; Wysocki, Rafael J <rafael.j.wysocki@intel.com>;
> > lenb@kernel.org
> > Cc: linux-acpi@vger.kernel.org; devel@acpica.org; linux-
> > kernel@vger.kernel.org; Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> > Subject: [PATCH] ACPICA:dbnames: Fix a error free in
> > acpi_db_walk_for_fields
> >
> > In acpi_db_walk_for_fields, buffer.pointer is freed in the first
> > time via ACPI_FREE() after acpi_os_printf("%s ", (char *)buffer.pointer).
> > But later, buffer.pointer is assigned to ret_value, and the freed
> > pointer is dereferenced by ret_value, which is use after free.
> >
> > In addition, buffer.pointer is freed by ACPI_FREE() again after
> > acpi_os_printf("}\n"), which is a double free.
> >
> > My patch removes the first ACPI_FREE() to avoid the uaf and double
> > free bugs.
> >
> 
> I'll take a look
> 
> Thanks
> 
> > Fixes: 5fd033288a866 ("ACPICA: debugger: add command to dump all fields
> > of particular subtype")
> > Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> > ---
> >  drivers/acpi/acpica/dbnames.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
> > index 3615e1a6efd8..dabd76df15ec 100644
> > --- a/drivers/acpi/acpica/dbnames.c
> > +++ b/drivers/acpi/acpica/dbnames.c
> > @@ -547,7 +547,6 @@ acpi_db_walk_for_fields(acpi_handle obj_handle,
> >  	}
> >
> >  	acpi_os_printf("%s ", (char *)buffer.pointer);
> > -	ACPI_FREE(buffer.pointer);

This is freeing the pointer allocated by acpi_ns_handle_to_pathname

> >
> >  	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
> >  	acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);

This call to acpi_evaluate_object will allocate an object in Buffer.Pointer object so the dereference of buffer->pointer is not a use after free

> > --
> > 2.25.1
> >


      reply	other threads:[~2021-05-05 23:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27  1:41 [PATCH] ACPICA:dbnames: Fix a error free in acpi_db_walk_for_fields Lv Yunlong
2021-04-29 18:00 ` Kaneda, Erik
2021-05-05 23:11   ` Kaneda, Erik [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=MWHPR11MB15993557BD12B767517A09B4F0599@MWHPR11MB1599.namprd11.prod.outlook.com \
    --to=erik.kaneda@intel.com \
    --cc=devel@acpica.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyl2019@mail.ustc.edu.cn \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).