Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp325537lqt; Thu, 6 Jun 2024 05:04:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYsYDk65U50lTIoNdsr3OEoxJkyhwrLTU/9X+qXpcotwRqkTsuE0n+B9odcwL4Dln/+35Tg3w0Z3IKzQt5WUKvHU8sft6LT+Qzp41nWA== X-Google-Smtp-Source: AGHT+IHfuY8hMwOT78HT+jmLD2kGg/oEEBw7yrGU0wXFhNAPoAdhT4gDm1p5rfL7PSeJ8H+KlX4O X-Received: by 2002:a50:9b13:0:b0:579:c8cb:ec3d with SMTP id 4fb4d7f45d1cf-57a8bcd6c67mr3318707a12.37.1717675451264; Thu, 06 Jun 2024 05:04:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717675451; cv=pass; d=google.com; s=arc-20160816; b=doBI1iNOn2782WSB/kptBk2VPb3uTncUxtAbXN/BY47oJ9XlbVcY0kyUrCG43wQtLi A3PxAi/jjgij8YUNjXA4hlxPFRHn/Y2TrVb5tFQ0X0setv/cN4os2rU+dHheKW3Xo/Uu 9U7s3G4wr5ZIKTzKwX2unr9lawqw5rRlv1BgL0itm+dT97zkLzpJ3urytztLGLPDoWVF E4eqfDsttIbLddjdVuPVEHlnEaPWFbI4Frb2Efh8ELEzphTgecZI1OcdJY/lCSWAgujS behlH8J7JXsEfhcgES/ZjmZnIKZhheKsN5AyBAMaAaVqvSW/sSQKPmReoxgT3h2d5qAf ohCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=Hbdq/RsCgFWFbIG6n/9OvqIQFuGH2NUTGrSCEJC1KsM=; fh=4XCtcOoeWh3qCl0Ks9JCjOTwCvgkcLOFk5uDh4JuAZk=; b=M+MYJNcdOWiATAVGTGmrAaiw1UrQYkmc8Bpk0/Z3aI6E67ojvTZlPahG+BafZ7wHdi 9poZEYguGqbaSXKuxBQYReWrvNOZIp2QbCxp5dogiyPVfye/FxTI72XE2l2LdT9cQngy LCHuoqa4VqIMQ7HrngAv0B0jwTe7Ex0xBBqCZV7TK4T2pizgRFX1mUFz24cBnaldbaov vnl9ZaPOa78Ac74ci5D8RRtYU+8qNbnKxWIHy4Q2s+Z9o69EJaF56HkDkHTPsgh7O8ER +wX2y7xobOpcpz4/KyQtsd4+Y/mL2Zp6ogNrBLEVNt4bPkVXYdMsTV/Xn8CtxcQ3jt0M RSrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Wr0d40gA; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-crypto+bounces-4787-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae0fc1e0si595202a12.188.2024.06.06.05.04.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 05:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4787-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Wr0d40gA; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-crypto+bounces-4787-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.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 am.mirrors.kernel.org (Postfix) with ESMTPS id F06761F257A8 for ; Thu, 6 Jun 2024 12:04:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0243E14D29E; Thu, 6 Jun 2024 12:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Wr0d40gA" X-Original-To: linux-crypto@vger.kernel.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 A24531957FC for ; Thu, 6 Jun 2024 12:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675436; cv=none; b=KdhsQHyDgQYHEmbN+q1+49f9vzLJfLQUrhExGjkiq5kRiBcIy7C17cgeatdgKFuOBtE2MfaNQVNrg0gMNZSl6N7fL91tZ4/3NbNeYQrN/fAL42aGJdzH/nWV8NGOiGJ2Fmjy8/0xzJtx176/Ag6OCj0suFWHWtIVpEQtvMYbuy4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675436; c=relaxed/simple; bh=DDjp6SAOUmiaQhinPu0H4EgZL7a3XELcpC/m7+nYolk=; h=From:To:CC:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=SrYl0ZuAMWE9Fso6t3pbfk0uyRoZoD+MWuganZoMzolMT9x81sAaXS8bguMNrbMyp9kCObEkJ8DYyKOteAyba3K1pLBUwB3kmPsju+2TKIOIOU+L3OnVi12nmYp+2YMJ0VjYMyKWH+qG+oiw3MPnoM+BAZCDWwy6+r/vMlMlTt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Wr0d40gA; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 456C3hRc106199; Thu, 6 Jun 2024 07:03:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717675423; bh=Hbdq/RsCgFWFbIG6n/9OvqIQFuGH2NUTGrSCEJC1KsM=; h=From:To:CC:Subject:In-Reply-To:References:Date; b=Wr0d40gAYhOy58FPtiMyy3twVlb3CwU2zi/qp/gStTDIhqDqFQfM72U3C79Ajr1yW f/jMEPFUdmDBDsKiHudRhuLIjsaAd3dufrjnPbm4iQjbEEchNcG0C4LmbC1ABhRJ+h XqTzISeQ2T9JPp5ZGy4RWeuEOcbKhXfzKjBH+TL0= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 456C3h4l115799 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Jun 2024 07:03:43 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 6 Jun 2024 07:03:42 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 6 Jun 2024 07:03:42 -0500 Received: from localhost (kamlesh.dhcp.ti.com [172.24.227.123]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 456C3gTk048792; Thu, 6 Jun 2024 07:03:42 -0500 From: Kamlesh Gurudasani To: Herbert Xu CC: , , , Subject: Re: [RFC] crypto: sa2ul - sha1/sha256/sha512 support In-Reply-To: References: <878r02f6bv.fsf@kamlesh.i-did-not-set--mail-host-address--so-tickle-me> <87bk4fa7dd.fsf@kamlesh.i-did-not-set--mail-host-address--so-tickle-me> Date: Thu, 6 Jun 2024 17:33:41 +0530 Message-ID: <875xum9t2a.fsf@kamlesh.i-did-not-set--mail-host-address--so-tickle-me> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Herbert Xu writes: > On Wed, Jun 05, 2024 at 06:12:22PM +0530, Kamlesh Gurudasani wrote: >> >> The way I understand algif_hash calls the digest function[0] if entire >> file(file whose SHA needs to be calculated) is less than 16 * >> PAGE_SIZE(4 kb for us) > > If that is the concern we should explore increasing the limit, > or at least making it configurable. The limit exists in order > to prevent user-space from exhausting kernel memory, so it is > meant to be admin-configurable. Increasing the limit is do able. But even if we increase the limit to ~1Mb. Calculating the file with size bigger than that will again fall back to init-> update -> finup. Also, the size that can be held by one sg list [0] is 204 entries, which can hold upto 800KB of data. I'm not sure if this is still true. Old article. If we consider chaining we can have more data, not sure how HW handles that. If the file size is about 100 MB in that case it will fallback to init -> update -> finup. If at max I can get 800KB, then I think it would be better if we save 64kb in context and implement virtual finup in init -> update -> final. Allocating 800kb in algif_hash module vs 64kb in sa2ul driver. This would be generic solution and will fit all scenarios. If we rely on digest, it will always have some limitation. Like if user allocates only 5MB buffer and file size was 10MB and data came in two update() instead of one digest(). (MSG_MORE flag scenario in algif_hash) [0]https://lwn.net/Articles/234617/ Cheers, Kamlesh > > Cheers, > -- > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt