Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1493506lqa; Mon, 29 Apr 2024 09:57:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8NmEZSjuWmze4ZoALn2ShV0il/7NAq1mv8HzNGj1gG4jBUJn8hZXPsIxdVce5sW4RXc1nYRJUkO5gaN/0a94Z+3or/3D1MwaUV4nHMw== X-Google-Smtp-Source: AGHT+IHccKLi8B2OH5lDbV9jYRE4PvMb5dW7rXSuXy0hHrYOH7PmXE2Iwh0upPZGnJMrW1ccBg9/ X-Received: by 2002:ae9:e643:0:b0:790:5dab:f730 with SMTP id x3-20020ae9e643000000b007905dabf730mr109404qkl.55.1714409858951; Mon, 29 Apr 2024 09:57:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714409858; cv=pass; d=google.com; s=arc-20160816; b=Bklu4QaZRdWw2Tgnn2pTZDWq91nKbmYNCZXdvl0U+pfVZ5j3B/nXxcXQt6OJtMBctF SKlnGRXfZ2zWWQKdAG5M4+hasroan4cT5N2C1PHBmNZre2ZM0BPMXO1FQ8hb31WD44Wb zMmWa+qSYkIBSIEAZIMIEZ6eQzKFUdUbxJwZCzRAFaLfyHsZF7TX1Ij/r2i93iCyiiXM WqCo+AtJxrF886XJ4Qp6rLV5cvh0FvkndImwaEEYS5uN9JAu/4E83DOXqEQ5zCixjsPK HIU/sFaOqkOejnYs7FKcaQ7dEoy4b07dVySa092TIBcPhhNXjXdGtoOMvaX0LjOO2oIt 2QGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=xuoovfx2POhGX/fjXgHfC5zmT1B1rEDq+Am+MvjR7Dk=; fh=vrTcvqufaKVRDtC42e97Tmt8E5nQG05k1N5ENiDsoQw=; b=j5gV1lxD/9YqXSHFG5V41ZqS8PbDVyyL7GgIC1llK+fyh+qtCBkUwM3BK6KlPSXrme CJFHbQeGhdKAotZS6wUlFQBuDYZ6IYCoz0Cr4XiinJ6TPe8xaHq/ozVkMhxx0iNAOomt N7WtQNgmpTNsH+m01IBSsk4G5bD/O8JEyGysNB8hVQRyxmxwwUGv/Z06u23D1qKQ1yze v0k1uCOwXBoZNFIOVZ7GihxU+8F6Kr7SyRQ0vV4dylUUnVW33QtBrcSPS9ymZUc/dvYl vgAq64zaf2mJ6GRhchldvLiF8fTk2LJfvHUeY+p+9hQ3WxW9HoOpoo4vpfaZKnvLUrXf PTbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bqMkonM1; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-crypto+bounces-3936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bq41-20020a05620a46a900b00790fb683e3bsi1946069qkb.603.2024.04.29.09.57.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:57:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bqMkonM1; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-crypto+bounces-3936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 943981C21333 for ; Mon, 29 Apr 2024 16:57:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 860E986244; Mon, 29 Apr 2024 16:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bqMkonM1" X-Original-To: linux-crypto@vger.kernel.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 1D9CC8613E; Mon, 29 Apr 2024 16:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714409854; cv=none; b=A3Z+vlFcs0D2AWFKC9kl3ec8LgsMXfblWwHy01xvM/xjg2yZCU2mQQyEOFgugpvUYk6GZfcLnXcQkhqkxkMaUpBXtOfMVKmbiAUQ78DNzAT0IrV2tt0F7EVp0H8ASQL8zlOqoka8TTc09u1qPTgEC5NJDKXNIB583tjG8v9RkyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714409854; c=relaxed/simple; bh=/SuGvf8UkdCZnz5+I7ZPOCp3GfImi4Fd9AOTgaarsnw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=H1Tvft/pX0cmMAFQGEMTKTbZrBgE+v77udecIo2FxBRPefChSvdJjCiAn4VrNv0PmXkbxwk9hVOPRr640p+xQaRv6sY5H8DRQlA3J9vxmGzZ3clPTFvEy1RmR8wtVpZRvP2wfqcYhj8duSW3fBrcDjiYLzlDQpIbqQgEGg3mdOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=bqMkonM1; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TG2DOO005539; Mon, 29 Apr 2024 16:57:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=xuoovfx2POhGX/fjXgHfC5zmT1B1rEDq+Am+MvjR7Dk=; b=bqMkonM1zBlCPV9qJae6YHqtEmjrt+Ujqu3sxHVKbyKOoX8qveHu5f1GdmQYzHuz5x2u 2qjPNyAmxaDNUdWP0ZcYonOG5yTC47rFkIc0ISi/qfSoFbGAo2JHLdUOfaiu6GewaK78 mWRK7XCp2rhDfxYdEepLNbU0ARFJIT1JCwIoTAVNvROGwMBy/djpIHqt5wFF3bdQw0YF C+77e890foTPbWVMKMRANENqfeR+7V5KXl4umPe9zp6ADduVUcW2o5g8XzdcAGbU0BZl ij8HJmGmQD3jnxUeq/Em6HBhz2uYfKD3LA+ImsnSe9rdz1Ryan8QpHoLQcitEDr8vl5f cg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xteqar5nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Apr 2024 16:57:26 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43TE8HVf027569; Mon, 29 Apr 2024 16:57:25 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xsc308jkc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Apr 2024 16:57:25 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43TGvMKo21168688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 16:57:24 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A65058058; Mon, 29 Apr 2024 16:57:22 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D458858057; Mon, 29 Apr 2024 16:57:21 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 29 Apr 2024 16:57:21 +0000 (GMT) Message-ID: Date: Mon, 29 Apr 2024 12:57:21 -0400 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] crypto: ecc - Prevent ecc_digits_from_bytes from reading too many bytes To: Jarkko Sakkinen , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, lukas@wunner.de References: <20240429161316.3146626-1-stefanb@linux.ibm.com> Content-Language: en-US From: Stefan Berger In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: b67sJDTXArPPA2BrAC3Tgs_2GLeWBIsP X-Proofpoint-ORIG-GUID: b67sJDTXArPPA2BrAC3Tgs_2GLeWBIsP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_14,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 adultscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 phishscore=0 clxscore=1015 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290109 On 4/29/24 12:47, Jarkko Sakkinen wrote: > On Mon Apr 29, 2024 at 7:13 PM EEST, Stefan Berger wrote: >> Prevent ecc_digits_from_bytes from reading too many bytes from the input >> byte array in case an insufficient number of bytes is provided to fill the >> output digit array of ndigits. Therefore, initialize the most significant >> digits with 0 to avoid trying to read too many bytes later on. Convert the >> function into a regular function since it is getting too big for an inline >> function. >> >> If too many bytes are provided on the input byte array the extra bytes >> are ignored since the input variable 'ndigits' limits the number of digits >> that will be filled. >> >> Fixes: d67c96fb97b5 ("crypto: ecdsa - Convert byte arrays with key coordinates to digits") >> Signed-off-by: Stefan Berger >> >> --- >> >> v2: >> - un-inline function >> - use memset >> --- >> crypto/ecc.c | 22 ++++++++++++++++++++++ >> include/crypto/internal/ecc.h | 15 ++------------- >> 2 files changed, 24 insertions(+), 13 deletions(-) >> >> diff --git a/crypto/ecc.c b/crypto/ecc.c >> index c1d2e884be1e..fe761256e335 100644 >> --- a/crypto/ecc.c >> +++ b/crypto/ecc.c >> @@ -68,6 +68,28 @@ const struct ecc_curve *ecc_get_curve(unsigned int curve_id) >> } >> EXPORT_SYMBOL(ecc_get_curve); >> > > Just a minor nit: > > For exported symbol you need to document the function,including > the parameters [1]. Like other functions, the ecc_digits_from_bytes also still/already has the documentation in the header file: /** * ecc_digits_from_bytes() - Create ndigits-sized digits array from byte array * @in: Input byte array * @nbytes Size of input byte array * @out Output digits array * @ndigits: Number of digits to create from byte array */ void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes, u64 *out, unsigned int ndigits); Should be ok?