From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 714382F873; Tue, 21 May 2024 06:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716272479; cv=none; b=m5KGJW9XPMcotqgb+7MMK2nl/ozZqgFi/qdDeO9JTbR5iD64waPj/pQuNwqyH18c1icjzjStU/oZOG5ezOa05MQ7gBGkh2z1pXFrbiEat/GzKmUWuFLk0pWxPRy3XbYZ0Ox5fMxZItjSqk8yQATBR3k5ftSM8VseLtTzXq1iY6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716272479; c=relaxed/simple; bh=QyUpE9XMBlIHRQI24cofeK5f6AJE0q3j683mGK5cjDY=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=kJ1LW1FEAO6obSAZnQhd235kSPdukWAcGCE9e//h51ofpJkKijoFMS9yOKAdNNnUeDHsBVUxximAhB/btsKauRaocmJ790V0FIDhqvto1G2lb2qLg91JUnpZfS67TYXO2jXRwlsJlb05hzSUDdLiCfPFe5CR6Vx5nMC5Rqoiem8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zk6wIy05; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zk6wIy05" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 164CBC2BD11; Tue, 21 May 2024 06:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716272479; bh=QyUpE9XMBlIHRQI24cofeK5f6AJE0q3j683mGK5cjDY=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=Zk6wIy05euOzmcXyJOhTEMXSwUCBLLbNmutx4DJWeQKgDBCsGHTdgJ2ye40xhT7Bx E7tEs0ICA6UnoPtZidAmJxR96tVEtqw24CCfjv1adGEOR/xwiPFEhgF8pMWYvuD4fn +Ftd7ZLD2YAeivD+WrNUfCbSwlAea0diZhY67GXE9g4LzIOoGU8JAHVzv7/ZCWFgTu V0UVpqskI52zf4oDajPygkppndTTDdoKh5vOLY3CleXkGNugG2kKf6YWD8BFCC9APH rKAJPHN19uITBasQD8Id7qIkJY2krieGpzuHRpuwIB4Hx2vylCiM8myEHLudLfkCiy LCmB8FfKRf3ww== Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 21 May 2024 09:21:13 +0300 Message-Id: Cc: "linux-integrity@vger.kernel.org" , "keyrings@vger.kernel.org" , "Andreas.Fuchs@infineon.com" , "James Prestwood" , "David Woodhouse" , "Eric Biggers" , "James Bottomley" , "David S. Miller" , "open list:CRYPTO API" , "open list" , "Andrew Morton" , "James Bottomley" , "Mimi Zohar" , "David Howells" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , "open list:SECURITY SUBSYSTEM" Subject: Re: [EXTERNAL] [PATCH v2 2/6] lib: Expand asn1_encode_integer() to variable size integers From: "Jarkko Sakkinen" To: "Bharat Bhushan" , "Herbert Xu" X-Mailer: aerc 0.17.0 References: <20240521031645.17008-1-jarkko@kernel.org> <20240521031645.17008-3-jarkko@kernel.org> In-Reply-To: < On Tue May 21, 2024 at 8:36 AM EEST, Bharat Bhushan wrote: > > - data_len -=3D 2; > > + (*data++) =3D _tag(UNIV, PRIM, INT); > > Just for my clarification:=20 > First index of "data" is updated here with tag and data pointer incremen= ted. > Next comment for continuation > > > + data_len--; > >=20 > > - data[0] =3D _tag(UNIV, PRIM, INT); > > - if (integer =3D=3D 0) { > > - *d++ =3D 0; > > - goto out; > > + if (!memchr_inv(integer, 0, integer_len)) { > > + data[1] =3D 1; > > + data[2] =3D 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