diff mbox series

libnvdimm: Add a NULL entry to 'nvdimm_firmware_attributes'

Message ID 20200814150509.225615-1-vaibhav@linux.ibm.com (mailing list archive)
State Not Applicable
Headers show
Series libnvdimm: Add a NULL entry to 'nvdimm_firmware_attributes' | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (f04b169e953c4db1a3a3c1d23eea09c726f01ee5)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (a7aaa2f26bfd932a654706b19859e7adf802bee2)
snowpatch_ozlabs/apply_patch success Successfully applied on branch linus/master (a1d21081a60dfb7fddf4a38b66d9cef603b317a9)
snowpatch_ozlabs/build-ppc64le warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/build-ppc64be warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/build-ppc64e warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/build-pmac32 warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
snowpatch_ozlabs/needsstable success Patch fixes a commit that hasn't been released yet

Commit Message

Vaibhav Jain Aug. 14, 2020, 3:05 p.m. UTC
We recently discovered a kernel oops with 'papr_scm' module while
booting ppc64 phyp guest with following back-trace:

BUG: Kernel NULL pointer dereference on write at 0x00000188
Faulting instruction address: 0xc0000000005d7084
Oops: Kernel access of bad area, sig: 11 [#1]
<snip>
Call Trace:
 internal_create_group+0x128/0x4c0 (unreliable)
 internal_create_groups.part.4+0x70/0x130
 device_add+0x458/0x9c0
 nd_async_device_register+0x28/0xa0 [libnvdimm]
 async_run_entry_fn+0x78/0x1f0
 process_one_work+0x2c0/0x5b0
 worker_thread+0x88/0x650
 kthread+0x1a8/0x1b0
 ret_from_kernel_thread+0x5c/0x6c

A bisect lead to the 'commit 48001ea50d17f ("PM, libnvdimm: Add runtime
firmware activation support")' and on investigation discovered that
the newly introduced 'struct attribute *nvdimm_firmware_attributes[]'
is missing a terminating NULL entry in the array. This causes a loop
in sysfs's 'create_files()' to read garbage beyond bounds of
'nvdimm_firmware_attributes' and trigger the oops.

Fixes: 48001ea50d17f ("PM, libnvdimm: Add runtime firmware activation support")
Reported-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 drivers/nvdimm/dimm_devs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ira Weiny Aug. 14, 2020, 5:10 p.m. UTC | #1
On Fri, Aug 14, 2020 at 08:35:09PM +0530, Vaibhav Jain wrote:
> We recently discovered a kernel oops with 'papr_scm' module while
> booting ppc64 phyp guest with following back-trace:
> 
> BUG: Kernel NULL pointer dereference on write at 0x00000188
> Faulting instruction address: 0xc0000000005d7084
> Oops: Kernel access of bad area, sig: 11 [#1]
> <snip>
> Call Trace:
>  internal_create_group+0x128/0x4c0 (unreliable)
>  internal_create_groups.part.4+0x70/0x130
>  device_add+0x458/0x9c0
>  nd_async_device_register+0x28/0xa0 [libnvdimm]
>  async_run_entry_fn+0x78/0x1f0
>  process_one_work+0x2c0/0x5b0
>  worker_thread+0x88/0x650
>  kthread+0x1a8/0x1b0
>  ret_from_kernel_thread+0x5c/0x6c
> 
> A bisect lead to the 'commit 48001ea50d17f ("PM, libnvdimm: Add runtime
> firmware activation support")' and on investigation discovered that
> the newly introduced 'struct attribute *nvdimm_firmware_attributes[]'
> is missing a terminating NULL entry in the array. This causes a loop
> in sysfs's 'create_files()' to read garbage beyond bounds of
> 'nvdimm_firmware_attributes' and trigger the oops.
> 
> Fixes: 48001ea50d17f ("PM, libnvdimm: Add runtime firmware activation support")
> Reported-by: Sandipan Das <sandipan@linux.ibm.com>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> ---
>  drivers/nvdimm/dimm_devs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 61374def51555..b59032e0859b7 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -529,6 +529,7 @@ static DEVICE_ATTR_ADMIN_RW(activate);
>  static struct attribute *nvdimm_firmware_attributes[] = {
>  	&dev_attr_activate.attr,
>  	&dev_attr_result.attr,
> +	NULL,
>  };
>  
>  static umode_t nvdimm_firmware_visible(struct kobject *kobj, struct attribute *a, int n)
> -- 
> 2.26.2
>
Verma, Vishal L Aug. 14, 2020, 10:55 p.m. UTC | #2
On Fri, 2020-08-14 at 10:10 -0700, Ira Weiny wrote:
> On Fri, Aug 14, 2020 at 08:35:09PM +0530, Vaibhav Jain wrote:
> > We recently discovered a kernel oops with 'papr_scm' module while
> > booting ppc64 phyp guest with following back-trace:
> > 
> > BUG: Kernel NULL pointer dereference on write at 0x00000188
> > Faulting instruction address: 0xc0000000005d7084
> > Oops: Kernel access of bad area, sig: 11 [#1]
> > <snip>
> > Call Trace:
> >  internal_create_group+0x128/0x4c0 (unreliable)
> >  internal_create_groups.part.4+0x70/0x130
> >  device_add+0x458/0x9c0
> >  nd_async_device_register+0x28/0xa0 [libnvdimm]
> >  async_run_entry_fn+0x78/0x1f0
> >  process_one_work+0x2c0/0x5b0
> >  worker_thread+0x88/0x650
> >  kthread+0x1a8/0x1b0
> >  ret_from_kernel_thread+0x5c/0x6c
> > 
> > A bisect lead to the 'commit 48001ea50d17f ("PM, libnvdimm: Add runtime
> > firmware activation support")' and on investigation discovered that
> > the newly introduced 'struct attribute *nvdimm_firmware_attributes[]'
> > is missing a terminating NULL entry in the array. This causes a loop
> > in sysfs's 'create_files()' to read garbage beyond bounds of
> > 'nvdimm_firmware_attributes' and trigger the oops.
> > 
> > Fixes: 48001ea50d17f ("PM, libnvdimm: Add runtime firmware activation support")
> > Reported-by: Sandipan Das <sandipan@linux.ibm.com>
> > Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> 
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>

Thanks Vaibhav and Ira. I see this was also reported and fixed by Zqiang
a couple days ago. I'll pick that, merge these trailers and add it to
the fixes queue.

> 
> > ---
> >  drivers/nvdimm/dimm_devs.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> > index 61374def51555..b59032e0859b7 100644
> > --- a/drivers/nvdimm/dimm_devs.c
> > +++ b/drivers/nvdimm/dimm_devs.c
> > @@ -529,6 +529,7 @@ static DEVICE_ATTR_ADMIN_RW(activate);
> >  static struct attribute *nvdimm_firmware_attributes[] = {
> >  	&dev_attr_activate.attr,
> >  	&dev_attr_result.attr,
> > +	NULL,
> >  };
> >  
> >  static umode_t nvdimm_firmware_visible(struct kobject *kobj, struct attribute *a, int n)
> > -- 
> > 2.26.2
> > 
> _______________________________________________
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
diff mbox series

Patch

diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index 61374def51555..b59032e0859b7 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -529,6 +529,7 @@  static DEVICE_ATTR_ADMIN_RW(activate);
 static struct attribute *nvdimm_firmware_attributes[] = {
 	&dev_attr_activate.attr,
 	&dev_attr_result.attr,
+	NULL,
 };
 
 static umode_t nvdimm_firmware_visible(struct kobject *kobj, struct attribute *a, int n)