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: <20250218170844.00000e2a@huawei.com>
Date: Tue, 18 Feb 2025 17:08:44 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Yuquan Wang <wangyuquan1236@...tium.com.cn>
CC: Fan Ni <nifan.cxl@...il.com>, <dave@...olabs.net>, <dave.jiang@...el.com>,
	<alison.schofield@...el.com>, <vishal.l.verma@...el.com>,
	<ira.weiny@...el.com>, <dan.j.williams@...el.com>,
	<linux-cxl@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<chenbaozi@...tium.com.cn>
Subject: Re: [PATCH v3 1/1] cxl/pmem: debug invalid serial number data

On Tue, 18 Feb 2025 11:01:23 +0800
Yuquan Wang <wangyuquan1236@...tium.com.cn> wrote:

> On Mon, Feb 17, 2025 at 06:20:18PM -0800, Fan Ni wrote:
> > On Tue, Feb 18, 2025 at 09:47:46AM +0800, Yuquan Wang wrote:  
> > > In a nvdimm interleave-set each device with an invalid or zero
> > > serial number may cause pmem region initialization to fail, but in
> > > cxl case such device could still set cookies of nd_interleave_set
> > > and create a nvdimm pmem region.
> > > 
> > > This adds the validation of serial number in cxl pmem region creation.
> > > The event of no serial number would cause to fail to set the cookie
> > > and pmem region.
> > > 
> > > For cxl-test to work properly, always +1 on mock device's serial
> > > number.
> > > 
> > > Signed-off-by: Yuquan Wang <wangyuquan1236@...tium.com.cn>
> > > ---
> > >  drivers/cxl/pmem.c           | 8 ++++++++
> > >  tools/testing/cxl/test/mem.c | 2 +-
> > >  2 files changed, 9 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> > > index f9c95996e937..73787afe1b9d 100644
> > > --- a/drivers/cxl/pmem.c
> > > +++ b/drivers/cxl/pmem.c
> > > @@ -383,6 +383,14 @@ static int cxl_pmem_region_probe(struct device *dev)
> > >  			.position = i,
> > >  		};
> > >  		info[i].offset = m->start;
> > > +
> > > +		if (cxlds->serial == 0) {
> > > +			/* include missing alongside invalid in this error message. */
> > > +			dev_err(dev, "%s: invalid or missing serial number\n",
> > > +				dev_name(&cxlmd->dev));
> > > +			rc = -ENXIO;
> > > +			goto out_nvd;
> > > +		}  
> > 
> > Should we do the check earlier in the code? 
> > For example, right below if (!nvdimm) {}
> > 
> > Fan  
> 
> I agree. This would removes unnecessary struct value assignments
> and make the code easier to read. Jonathan, what's your opinion?
> 

Seems a bit odd to move it well clear of where it is used.  You could
pull these two info[i] lines up as well then it would seem more reasonable.

I don't mind that much though.

Jonathan

> Yuquan
> 
> >   
> > >  		info[i].serial = cxlds->serial;
> > >  	}
> > >  	ndr_desc.num_mappings = cxlr_pmem->nr_mappings;
> > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> > > index 8d731bd63988..9e098cf06603 100644
> > > --- a/tools/testing/cxl/test/mem.c
> > > +++ b/tools/testing/cxl/test/mem.c
> > > @@ -1533,7 +1533,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
> > >  	mds->event.buf = (struct cxl_get_event_payload *) mdata->event_buf;
> > >  	INIT_DELAYED_WORK(&mds->security.poll_dwork, cxl_mockmem_sanitize_work);
> > >  
> > > -	cxlds->serial = pdev->id;
> > > +	cxlds->serial = pdev->id + 1;
> > >  	if (is_rcd(pdev))
> > >  		cxlds->rcd = true;
> > >  
> > > -- 
> > > 2.34.1
> > >   
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ