Received: by 10.223.185.116 with SMTP id b49csp4889913wrg; Wed, 7 Mar 2018 02:51:39 -0800 (PST) X-Google-Smtp-Source: AG47ELug2qd2hEXusb/Hkix55I1p1hS43SJr3ckbBGJTWDj6fTPD3bwiYSpfKfSdFHj+XDWAILx+ X-Received: by 2002:a17:902:7f0c:: with SMTP id d12-v6mr12345446plm.350.1520419898925; Wed, 07 Mar 2018 02:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520419898; cv=none; d=google.com; s=arc-20160816; b=Yq8nD8VhWY8RkilpPehnNb9KfCRfwr37mMTuEssYLRezDGjbsk9hmqLhwl6+B4z9kd iyrk6UxQHVx9xsHVl3MoKkxdiq7qKjJKQ1jKjyYuZFS9v66zEusQWuVj2eWPVV/CNYbQ FafW1gJzVS54BlHrHoh9/vkb4pL8et7z+qALm4eSWqb3uz2ksF/kDtJKKDsfFrgTMuZw 6JToN7+1JOhIhO3xtkYJGgDUeR7aRDhTdKh5gYacEmI+svX+po5keQfGMivlhX9f35Fr GrKQXoNCMXe+cE6XPfj/XyCVqNzPRhdJf6uoeZ3hmvVS0SfEJk8bPmZQlemLSvCv8yBW UeFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:cc:to:subject:from:dkim-signature:dkim-filter :arc-authentication-results; bh=QaQKBtSu1OOn7H4hJzPLan7m5IsDO0Icip+6v0394BI=; b=I2oB7V2yCIvcN5cMJ5WU92/Ik+xPOL5Gng6OnKfxb9BXMklV1jsKnqqsFSr6xoLB7p mBTLBPmhDnazn2mceB70H7zvpenW2Qm8zrVbSsIj3rWySfVy20ElSPkBLZz59B18BWaC DlmgpfK3XV25+qKKVOJxNVKKpVGnsOvvkkNDDWw27sqUigOMfXxf0aN/XyIs1MhO+IjV elonGtCfVYXMQgK+NYGirvPOYC+gE7IahVJpcV5phPGrFJ/HNzzJAXk/W/Q4dHJUw53a 4+AxR+Np7+TL2pX+A3wKOIkjh5EowJCwzuXNh6usOiAHbrXO414C17QLBhBeuMQwwWR4 zGiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=CvXvMODW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si11035959pga.394.2018.03.07.02.51.24; Wed, 07 Mar 2018 02:51:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=CvXvMODW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754235AbeCGKtn (ORCPT + 99 others); Wed, 7 Mar 2018 05:49:43 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:38293 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbeCGKti (ORCPT ); Wed, 7 Mar 2018 05:49:38 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180307104936euoutp021d7f218b19ac15f72fbe23d5a5a89210~ZnbsV1Gbh1739017390euoutp02R; Wed, 7 Mar 2018 10:49:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180307104936euoutp021d7f218b19ac15f72fbe23d5a5a89210~ZnbsV1Gbh1739017390euoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520419776; bh=QaQKBtSu1OOn7H4hJzPLan7m5IsDO0Icip+6v0394BI=; h=From:Subject:To:Cc:Date:References:From; b=CvXvMODWBVhO5cEAWXSymCMquYN/fhG7LSQJXWOH34+0Ilcba3zHUkdp22Hcu3e5I C6YDxQk9EC0xGn0/IIuMpFLlh5dLQyq8mWR4hFBfTorp/EA5RKSvPd8bPI5nxoKDer kdBMfcuv3LZQTqzB9VtJAe2f4hVJXwclp8qdY2Vk= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180307104935eucas1p269eaaa11f013b7c305848f43d487117b~ZnbrrRRX31694416944eucas1p28; Wed, 7 Mar 2018 10:49:35 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F3.F4.05700.FB3CF9A5; Wed, 7 Mar 2018 10:49:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180307104934eucas1p18af0e65a519299997b5d2f7fb78cd39f~ZnbqxaJg63037230372eucas1p1i; Wed, 7 Mar 2018 10:49:34 +0000 (GMT) X-AuditID: cbfec7f2-1dbff70000011644-1e-5a9fc3bfa569 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 91.34.04183.EB3CF9A5; Wed, 7 Mar 2018 10:49:34 +0000 (GMT) Received: from [106.120.51.18] by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5700022VEL1C20@eusync4.samsung.com>; Wed, 07 Mar 2018 10:49:34 +0000 (GMT) From: Kamil Konieczny Subject: [PATCH v2] crypto: hash.h: Prevent use of req->result in ahash update To: Herbert Xu Cc: "David S. Miller" , Bartlomiej Zolnierkiewicz , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Message-id: <7850c31c-8703-51fb-0710-3b4920935bfc@partner.samsung.com> Date: Wed, 07 Mar 2018 11:49:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-version: 1.0 Content-type: text/plain; charset="utf-8" Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7djP87r7D8+PMlj/kNli44z1rBZzzrew WHS/krG4f+8nk8XlXXPYHFg9tqy8yeSx7YCqR9+WVYwenzfJBbBEcdmkpOZklqUW6dslcGXM 6ikueCVasfn9NfYGxjmCXYycHBICJhLfP2xm7GLk4hASWMEosflrAzuE85lRYsP3NWwwVf0P LzNBJJYxSuzcfZUZwnnGKNGy+DAzSBWbgLnEo+1nmEBsYYEAid83poF1iwjoSKx8uZgVpIFZ YCGjxI/+8+wgCV4BN4n/91eCNbMIqEpsm/6QBcQWFYiQWDj1KSNEjaDEj8n3wOLMApoSL75M grLFJZpbb0LZ8hKb17xlhjh1DpvEjU0SELaLRNePDhYIW1ji1fEt7BC2jMTlyd1Q8XKJTVvW gv0sIdDAKLHmfRMjRMJa4vDxi6wQC/gkJm2bDrSAAyjOK9HRJgRR4iHx+PEhRoiwo0THEROQ sJBArMT8ZwtZJzDKzkLywSwkH8xC8sEsJB8sYGRZxSieWlqcm55abJiXWq5XnJhbXJqXrpec n7uJEZgaTv87/mkH49dLSYcYBTgYlXh4I/bOixJiTSwrrsw9xCjBwawkwju5ZH6UEG9KYmVV alF+fFFpTmrxIUZpDhYlcd44jbooIYH0xJLU7NTUgtQimCwTB6dUA2N67aR3ny7GX1pzW+r8 HMPQeqd3c+9VLtfzV2zzP3wu98TCBoFFc1qvP7oqJH5lI1t9+l6O5wESVSf9LoTNsJnwYO1D vrzEQzOmtB0/wfPyxoaVCZM/Xp3148LTF9MyexYVSk8KqGCeU/zE2sGRYWIny66VInmf7xxO DP85/9z5txcb7XuffQy6r8RSnJFoqMVcVJwIALV86S8JAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNLMWRmVeSWpSXmKPExsVy+t/xa7r7Ds+PMjjzXNBi44z1rBZzzrew WHS/krG4f+8nk8XlXXPYHFg9tqy8yeSx7YCqR9+WVYwenzfJBbBEcdmkpOZklqUW6dslcGXM 6ikueCVasfn9NfYGxjmCXYycHBICJhL9Dy8zdTFycQgJLGGUOHvzAyNIQkjgGaPEtTcpIDab gLnEo+1nmEBsYQE/iXcvzrKB2CICOhIrXy5mBWlmFljIKDFp8TFWkASvgJvE//srmUFsFgFV iW3TH7KA2KICERKdK+ezQNQISvyYfA/I5gBqVpeYMiUXJMwsIC7R3HqTBcKWl9i85i3zBEa+ WUg6ZiF0zELSMQtJxwJGllWMIqmlxbnpucVGesWJucWleel6yfm5mxiBQbrt2M8tOxi73gUf YhTgYFTi4d2wf16UEGtiWXFl7iFGCQ5mJRHeySXzo4R4UxIrq1KL8uOLSnNSiw8xSnOwKInz njeojBISSE8sSc1OTS1ILYLJMnFwSjUwHt8RbfLahWNpo5Xxp5KaTnPp1fGBC++LL9irs0GL T4kr9S1DVlHPfdtP5nMqVMzPzvw3X7Ha73tQxmPTr61sEVWytqsF8m8ILF13/LZQbo6Gu2WZ 4bfITyf3pj8RXvxtY1vdiwUq/X4JSn9zJJ9MvROrfmxGdf7cx//VXpQHzH5mwSSgFnZaiaU4 I9FQi7moOBEAPO1X0E4CAAA= X-CMS-MailID: 20180307104934eucas1p18af0e65a519299997b5d2f7fb78cd39f X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180307104934eucas1p18af0e65a519299997b5d2f7fb78cd39f X-RootMTR: 20180307104934eucas1p18af0e65a519299997b5d2f7fb78cd39f References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prevent improper use of req->result field in ahash update, init, export and import functions in drivers code. A driver should use ahash request context if it needs to save internal state. Signed-off-by: Kamil Konieczny --- version 2: Change req->digest to req->result, as pointed out by Tom Lendacky include/crypto/hash.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 2d1849dffb80..76e432cab75d 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -74,7 +74,8 @@ struct ahash_request { * @init: **[mandatory]** Initialize the transformation context. Intended only to initialize the * state of the HASH transformation at the beginning. This shall fill in * the internal structures used during the entire duration of the whole - * transformation. No data processing happens at this point. + * transformation. No data processing happens at this point. Driver code + * implementation must not use req->result. * @update: **[mandatory]** Push a chunk of data into the driver for transformation. This * function actually pushes blocks of data from upper layers into the * driver, which then passes those to the hardware as seen fit. This @@ -83,7 +84,8 @@ struct ahash_request { * transformation. This function shall not modify the transformation * context, as this function may be called in parallel with the same * transformation object. Data processing can happen synchronously - * [SHASH] or asynchronously [AHASH] at this point. + * [SHASH] or asynchronously [AHASH] at this point. Driver must not use + * req->result. * @final: **[mandatory]** Retrieve result from the driver. This function finalizes the * transformation and retrieves the resulting hash from the driver and * pushes it back to upper layers. No data processing happens at this @@ -120,11 +122,12 @@ struct ahash_request { * you want to save partial result of the transformation after * processing certain amount of data and reload this partial result * multiple times later on for multiple re-use. No data processing - * happens at this point. + * happens at this point. Driver must not use req->result. * @import: Import partial state of the transformation. This function loads the * entire state of the ongoing transformation from a provided block of * data so the transformation can continue from this point onward. No - * data processing happens at this point. + * data processing happens at this point. Driver must not use + * req->result. * @halg: see struct hash_alg_common */ struct ahash_alg { -- 2.16.2