Platform-driver-x86 Archive on lore.kernel.org
 help / color / Atom feed
From: "Yuan, Perry" <Perry.Yuan@dell.com>
To: "Limonciello, Mario" <Mario.Limonciello@dell.com>,
	Hans De Goede <hdegoede@redhat.com>,
	Mark Gross <mgross@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"platform-driver-x86@vger.kernel.org" 
	<platform-driver-x86@vger.kernel.org>,
	"Bharathi, Divya" <Divya.Bharathi@Dell.com>,
	"Ksr, Prasanth" <Prasanth.Ksr@dell.com>,
	"Martinez3, Juan" <Juan.Martinez@Dell.com>,
	"Wang, David D" <David.D.Wang@dell.com>
Subject: RE: [PATCH] platform/x86: dell-wmi-sysman: fix a NULL pointer dereference
Date: Sat, 30 Jan 2021 03:55:13 +0000
Message-ID: <SJ0PR19MB4528B841F60B7F86997FD19884B89@SJ0PR19MB4528.namprd19.prod.outlook.com> (raw)
In-Reply-To: <SA1PR19MB49265FC286F5D09F88F2A054FAB99@SA1PR19MB4926.namprd19.prod.outlook.com>

> -----Original Message-----
> From: Limonciello, Mario <Mario_Limonciello@Dell.com>
> Sent: 2021年1月30日 1:29
> To: Hans De Goede; Mark Gross
> Cc: LKML; platform-driver-x86@vger.kernel.org; Bharathi, Divya; Ksr, Prasanth;
> Yuan, Perry
> Subject: RE: [PATCH] platform/x86: dell-wmi-sysman: fix a NULL pointer
> dereference
> 
> +Divya, +Prasanth, +Perry
> 
> > -----Original Message-----
> > From: Limonciello, Mario <Mario_Limonciello@Dell.com>
> > Sent: Friday, January 29, 2021 11:27
> > To: Hans De Goede; Mark Gross
> > Cc: LKML; platform-driver-x86@vger.kernel.org; Limonciello, Mario
> > Subject: [PATCH] platform/x86: dell-wmi-sysman: fix a NULL pointer
> > dereference
> >
> > An upcoming Dell platform is causing a NULL pointer dereference in
> > dell-wmi-sysman initialization.  Validate that the input from BIOS
> > matches correct ACPI types and abort module initialization if it
> > fails.
> >
> > This leads to a memory leak that needs to be cleaned up properly.
> >
> > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> > ---
> >  drivers/platform/x86/dell-wmi-sysman/sysman.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/dell-wmi-sysman/sysman.c
> > b/drivers/platform/x86/dell-wmi-sysman/sysman.c
> > index dc6dd531c996..38b497991071 100644
> > --- a/drivers/platform/x86/dell-wmi-sysman/sysman.c
> > +++ b/drivers/platform/x86/dell-wmi-sysman/sysman.c
> > @@ -419,13 +419,19 @@ static int init_bios_attributes(int attr_type,
> > const char *guid)
> >  		return retval;
> >  	/* need to use specific instance_id and guid combination to get
> > right data */
> >  	obj = get_wmiobj_pointer(instance_id, guid);
> > -	if (!obj)
> > +	if (!obj || obj->type != ACPI_TYPE_PACKAGE) {
> > +		release_attributes_data();
> >  		return -ENODEV;
> > +	}
> >  	elements = obj->package.elements;
> >
> >  	mutex_lock(&wmi_priv.mutex);
> >  	while (elements) {
> >  		/* sanity checking */
> > +		if (elements[ATTR_NAME].type != ACPI_TYPE_STRING) {
> > +			pr_debug("incorrect element type\n");
> > +			goto nextobj;
> > +		}
> >  		if (strlen(elements[ATTR_NAME].string.pointer) == 0) {
> >  			pr_debug("empty attribute found\n");
> >  			goto nextobj;
> > --
> > 2.25.1

Tested on the Dell laptop system which I found the issue. 
Kernel can boot up with this new fix patch without any panic triggered.

Tested-by: Perry Yuan <perry_yuan@dell.com>

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-29 17:26 Mario Limonciello
2021-01-29 17:29 ` Limonciello, Mario
2021-01-30  3:55   ` Yuan, Perry [this message]
2021-01-30 21:43 ` Hans de Goede
     [not found]   ` <SA1PR19MB49263EE7ECF0D06962BE00ECFAB79@SA1PR19MB4926.namprd19.prod.outlook.com>
2021-01-31 20:59     ` Hans de Goede
2021-02-01  2:36       ` Perry Yuan
2021-02-01  8:27         ` Hans de Goede

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=SJ0PR19MB4528B841F60B7F86997FD19884B89@SJ0PR19MB4528.namprd19.prod.outlook.com \
    --to=perry.yuan@dell.com \
    --cc=David.D.Wang@dell.com \
    --cc=Divya.Bharathi@Dell.com \
    --cc=Juan.Martinez@Dell.com \
    --cc=Mario.Limonciello@dell.com \
    --cc=Prasanth.Ksr@dell.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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

Platform-driver-x86 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/platform-driver-x86/0 platform-driver-x86/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 platform-driver-x86 platform-driver-x86/ https://lore.kernel.org/platform-driver-x86 \
		platform-driver-x86@vger.kernel.org
	public-inbox-index platform-driver-x86

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.platform-driver-x86


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git