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: <YMn+wDYHux16HBhd@smile.fi.intel.com>
Date:   Wed, 16 Jun 2021 16:38:08 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
Cc:     Vaibhav Jain <vaibhav@...ux.ibm.com>,
        linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        Michael Ellerman <mpe@...erman.id.au>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Oliver O'Halloran <oohall@...il.com>
Subject: Re: [PATCH v1 1/1] powerpc/papr_scm: Properly handle UUID types and
 API

On Fri, Apr 16, 2021 at 03:05:31PM +0530, Aneesh Kumar K.V wrote:
> On 4/16/21 2:39 PM, Andy Shevchenko wrote:
> > On Fri, Apr 16, 2021 at 01:28:21PM +0530, Aneesh Kumar K.V wrote:
> > > On 4/15/21 7:16 PM, Andy Shevchenko wrote:
> > > > Parse to and export from UUID own type, before dereferencing.
> > > > This also fixes wrong comment (Little Endian UUID is something else)
> > > > and should fix Sparse warnings about assigning strict types to POD.
> > > > 
> > > > Fixes: 43001c52b603 ("powerpc/papr_scm: Use ibm,unit-guid as the iset cookie")
> > > > Fixes: 259a948c4ba1 ("powerpc/pseries/scm: Use a specific endian format for storing uuid from the device tree")
> > > > Cc: Oliver O'Halloran <oohall@...il.com>
> > > > Cc: Aneesh Kumar K.V <aneesh.kumar@...ux.ibm.com>
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> > > > ---
> > > > Not tested
> > > >    arch/powerpc/platforms/pseries/papr_scm.c | 13 ++++++++-----
> > > >    1 file changed, 8 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
> > > > index ae6f5d80d5ce..4366e1902890 100644
> > > > --- a/arch/powerpc/platforms/pseries/papr_scm.c
> > > > +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> > > > @@ -1085,8 +1085,9 @@ static int papr_scm_probe(struct platform_device *pdev)
> > > >    	u32 drc_index, metadata_size;
> > > >    	u64 blocks, block_size;
> > > >    	struct papr_scm_priv *p;
> > > > +	u8 uuid_raw[UUID_SIZE];
> > > >    	const char *uuid_str;
> > > > -	u64 uuid[2];
> > > > +	uuid_t uuid;
> > > >    	int rc;
> > > >    	/* check we have all the required DT properties */
> > > > @@ -1129,16 +1130,18 @@ static int papr_scm_probe(struct platform_device *pdev)
> > > >    	p->hcall_flush_required = of_property_read_bool(dn, "ibm,hcall-flush-required");
> > > >    	/* We just need to ensure that set cookies are unique across */
> > > > -	uuid_parse(uuid_str, (uuid_t *) uuid);
> > > > +	uuid_parse(uuid_str, &uuid);
> > > > +
> > > >    	/*
> > > >    	 * cookie1 and cookie2 are not really little endian
> > > > -	 * we store a little endian representation of the
> > > > +	 * we store a raw buffer representation of the
> > > >    	 * uuid str so that we can compare this with the label
> > > >    	 * area cookie irrespective of the endian config with which
> > > >    	 * the kernel is built.
> > > >    	 */
> > > > -	p->nd_set.cookie1 = cpu_to_le64(uuid[0]);
> > > > -	p->nd_set.cookie2 = cpu_to_le64(uuid[1]);
> > > > +	export_uuid(uuid_raw, &uuid);
> > > > +	p->nd_set.cookie1 = get_unaligned_le64(&uuid_raw[0]);
> > > > +	p->nd_set.cookie2 = get_unaligned_le64(&uuid_raw[8]);
> > > 
> > > ok that does the equivalent of cpu_to_le64 there. So we are good. But the
> > > comment update is missing the details why we did that get_unaligned_le64.
> > > Maybe raw buffer representation is the correct term?
> > > Should we add an example in the comment. ie,
> > 
> > > /*
> > >   * Historically we stored the cookie in the below format.
> > > for a uuid str 72511b67-0b3b-42fd-8d1d-5be3cae8bcaa
> > > cookie1 was  0xfd423b0b671b5172 cookie2 was 0xaabce8cae35b1d8d
> > > */
> > 
> > I'm fine with the comment. At least it will shed a light on the byte ordering
> > we are expecting.
> > 
> 
> Will you be sending an update? Also it will be good to list the sparse
> warning in the commit message?

I'll send an update but I rephrase to remove mention of Sparse. I have no
Sparse build for this architecture.

If you have one, try to build with `make W=1 C=1 CF=-D__CHECK_ENDIAN__ ...`
which will enable warnings about restricted types assignment.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ