[<prev] [next>] [day] [month] [year] [list]
Message-Id: <D1F3TDIAMTW0.2X7QDQ6TSUAGT@kernel.org>
Date: Tue, 21 May 2024 09:21:13 +0300
From: "Jarkko Sakkinen" <jarkko@...nel.org>
To: "Bharat Bhushan" <bbhushan2@...vell.com>, "Herbert Xu"
<herbert@...dor.apana.org.au>
Cc: "linux-integrity@...r.kernel.org" <linux-integrity@...r.kernel.org>,
"keyrings@...r.kernel.org" <keyrings@...r.kernel.org>,
"Andreas.Fuchs@...ineon.com" <Andreas.Fuchs@...ineon.com>, "James
Prestwood" <prestwoj@...il.com>, "David Woodhouse" <dwmw2@...radead.org>,
"Eric Biggers" <ebiggers@...nel.org>, "James Bottomley"
<James.Bottomley@...senpartnership.com>, "David S. Miller"
<davem@...emloft.net>, "open list:CRYPTO API"
<linux-crypto@...r.kernel.org>, "open list" <linux-kernel@...r.kernel.org>,
"Andrew Morton" <akpm@...ux-foundation.org>, "James Bottomley"
<James.Bottomley@...senPartnership.com>, "Mimi Zohar"
<zohar@...ux.ibm.com>, "David Howells" <dhowells@...hat.com>, "Paul Moore"
<paul@...l-moore.com>, "James Morris" <jmorris@...ei.org>, "Serge E.
Hallyn" <serge@...lyn.com>, "open list:SECURITY SUBSYSTEM"
<linux-security-module@...r.kernel.org>
Subject: Re: [EXTERNAL] [PATCH v2 2/6] lib: Expand asn1_encode_integer() to
variable size integers
On Tue May 21, 2024 at 8:36 AM EEST, Bharat Bhushan wrote:
> > - data_len -= 2;
> > + (*data++) = _tag(UNIV, PRIM, INT);
>
> Just for my clarification:
> First index of "data" is updated here with tag and data pointer incremented.
> Next comment for continuation
>
> > + data_len--;
> >
> > - data[0] = _tag(UNIV, PRIM, INT);
> > - if (integer == 0) {
> > - *d++ = 0;
> > - goto out;
> > + if (!memchr_inv(integer, 0, integer_len)) {
> > + data[1] = 1;
> > + data[2] = 0;
> > + return &data[2];
>
> Here we are effectively setting second and third index of original
> "data" pointer as "data" pointer was incremented earlier.
> So second index of original "data" pointer is not touched. Also
> returning 3rd index pointer of original data pointer
>
> Is that intentional?
No! I read the diff few times, and I think you have a point.
Indices should be 0 (length) and 1 (value). I.e. it forms an encoded
version of zero. The last index what it should be, i.e. return address
of the next byte after the encoded integer.
Thanks for pointing this out.
> Thanks
> -Bharat
BR, Jarkko
Powered by blists - more mailing lists