Received: by 10.223.185.116 with SMTP id b49csp3709253wrg; Tue, 6 Mar 2018 03:46:55 -0800 (PST) X-Google-Smtp-Source: AG47ELtt6CH3EWzfUkUnV5HnTaewTCYPWVzekzfct2wbKe0nIA5LR//VpNo2EL6dCMgbvkymABBQ X-Received: by 10.99.114.77 with SMTP id c13mr15141815pgn.8.1520336815033; Tue, 06 Mar 2018 03:46:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520336815; cv=none; d=google.com; s=arc-20160816; b=I7jGSLd7UbRXNjry2tUIvjZ6JI0qr19GvW9nzu1plYB0B/7dpyxnAPr+iQJV+8c2jV O1A1E2GB3SI0mwTObjZpEJ9B0+I2M+UEgFd8XmW9IYFN0m8FUHAIzWZeRjKLTXCyqyPY dPxZCLpVnH0z/mRg8FkHoD8TpZvn0JJQCPfSfYJrGxKsXXd04Y4E5zC76ZcWlJE3QyzK j96W7WbtlrRwjHSQItXK2hsNHkJq0HWrVs86+aMx8bEsH2Iq1errpb/9HaC3zh2adW4Z uYtOFGUk446OnrBmMfGNnCQqCIzLsU3J5PIHcbZnl75Xyyft5JKfDSaxabzS4xJuvIpu njyQ== 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:subject:from:cc:to:dkim-signature:dkim-filter :arc-authentication-results; bh=xjAcYYoouOuGfbOEt1Tm7/EyLSm0UbQDWw5jWGyljH4=; b=ycH+yCEeUONgk3zdw5GYRYHWZF+SHLhc1aiW6k7kVJmrl719neT/F959sXphJWXbLu r3wy3nVfRvMhPaEiDSnd1Mb0ZR4NIDuTkMISaQWCiZGvrG8ByGMUmg7z7s8aRpB3Bj1i AqROo/fUmHk7Iq53WRM4LLlg8I0q5JEJFuu92WxlMCZCxvaPvF/9/QeOo1CKzA+3dhiG vDGfh6SC8S+NFQ60V/3AIGatlJl7dbWXmt+C0wcIkBO2uW1nAkU8sGJ0XlxNaewhwijw oh2mVuOCifKyEyUCnSgDv8B7bHRCpuY+qP6b7n2zNeUB+UcZWK7kp3PzapZCuoQvz+gh bLow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LTQ25YYZ; 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 k11-v6si10882895plt.531.2018.03.06.03.46.39; Tue, 06 Mar 2018 03:46:54 -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=LTQ25YYZ; 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 S1753401AbeCFLpW (ORCPT + 99 others); Tue, 6 Mar 2018 06:45:22 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:32838 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838AbeCFLpR (ORCPT ); Tue, 6 Mar 2018 06:45:17 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180306114514euoutp02a51826088747bc8f9004acf7eee9d134~ZUi-cQh410186801868euoutp02V; Tue, 6 Mar 2018 11:45:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180306114514euoutp02a51826088747bc8f9004acf7eee9d134~ZUi-cQh410186801868euoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520336714; bh=xjAcYYoouOuGfbOEt1Tm7/EyLSm0UbQDWw5jWGyljH4=; h=To:Cc:From:Subject:Date:References:From; b=LTQ25YYZzpWP8d91iQ9V7RJd2S+h6FBDPvFLewXTsc9lW1zU6VcK4EvvDRt+36EJ2 FzNrecixeuttxWgb6FQDEJuM1pAHmYp65neu3jhRTDePXsybvV8iqSqI4dtqI2NM/p Mn9wW3cCloNZTnA1zbNpwDpJadCLeuEogCQWkQoI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180306114513eucas1p10b08a36fc45d0be37cd6ee98bb424a9d~ZUi_sab_f0184001840eucas1p1i; Tue, 6 Mar 2018 11:45:13 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 58.61.17380.94F7E9A5; Tue, 6 Mar 2018 11:45:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180306114512eucas1p286d36bafa1bc719d7e7ccbaa9f549fc1~ZUi9vWXjB0900909009eucas1p2W; Tue, 6 Mar 2018 11:45:12 +0000 (GMT) X-AuditID: cbfec7f4-6f9ff700000043e4-82-5a9e7f490570 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C8.B5.04178.84F7E9A5; Tue, 6 Mar 2018 11:45:12 +0000 (GMT) Received: from [106.120.51.18] by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P560085J3BCII50@eusync3.samsung.com>; Tue, 06 Mar 2018 11:45:12 +0000 (GMT) To: Herbert Xu Cc: "David S. Miller" , Bartlomiej Zolnierkiewicz , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org From: Kamil Konieczny Subject: [PATCH] crypto: hash.h: Prevent use of req->digest in ahash update Message-id: Date: Tue, 06 Mar 2018 12:45:11 +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+NgFvrGIsWRmVeSWpSXmKPExsWy7djPc7qe9fOiDE51iFtsnLGe1WLO+RYW i+5XMhb37/1ksri8aw6bA6vHlpU3mTy2HVD16NuyitHj8ya5AJYoLpuU1JzMstQifbsErox7 hz8zFcwSrTh94g5TA+NtgS5GTg4JAROJ+au7WEBsIYEVjBK3W2K7GLmA7M+MEmv+7mODKbqz fisjRGIZo0THhGZWCOcZo8SBWW3sIFUiAjoSK18uBkswCyxklPjRfx4swSZgLvFo+xmmLkYO DmEBb4mr24pBwrwCbhITX21iBLFZBFQlvp19DWaLCkRILJz6lBGiRlDix+R7YOcxC2hKvPgy CcoWl2huvQlly0tsXvOWGWSvhMAcNol7Sy4wQZztIjF93VVWCFtY4tXxLewQtoxEZ8dBqJpy iU1b1rJDNDcA/fy+iREiYS1x+PhFVogNfBKTtk1nBnlAQoBXoqNNCKLEQ+LwrbesEGFHiW+d fpBgjJX49W8y0wRG2VlIXpiF5IVZSF6YheSFBYwsqxjFU0uLc9NTi43yUsv1ihNzi0vz0vWS 83M3MQJTw+l/x7/sYNz1J+kQowAHoxIPL4f33Cgh1sSy4srcQ4wSHMxKIrwR+vOihHhTEiur Uovy44tKc1KLDzFKc7AoifPGadRFCQmkJ5akZqemFqQWwWSZODilGhjzNqiWuW6U+iN18nn1 dL8o9vub0u9yhdXc41YU3MfDpMXMb/o/bnvZIc5TV+3X7v7WtPjtofcSMW2zPAVWdCTPeqL/ /PavZJk+V7+WZs2njI7XFAxO73yUkHBMz+nUzP1bmKcZnteqXfWa3/fauQsxNS4b3VobN/Rx TDKepiTWEKoteHoL5wQlluKMREMt5qLiRACilUiKCQMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDLMWRmVeSWpSXmKPExsVy+t/xq7oe9fOiDHq6jC02zljPajHnfAuL RfcrGYv7934yWVzeNYfNgdVjy8qbTB7bDqh69G1ZxejxeZNcAEsUl01Kak5mWWqRvl0CV8a9 w5+ZCmaJVpw+cYepgfG2QBcjJ4eEgInEnfVbGbsYuTiEBJYwSmye94YdwnnGKPG4rZ8NpEpE QEdi5cvFrCAJZoGFjBKTFh9jBUmwCZhLPNp+hqmLkYNDWMBb4uq2YpAwr4CbxMRXmxhBbBYB VYlvZ1+D2aICERKdK+ezQNQISvyYfI8FpJVZQF1iypRckDCzgLhEc+tNFghbXmLzmrfMExj5 ZiHpmIXQMQtJxywkHQsYWVYxiqSWFuem5xYb6hUn5haX5qXrJefnbmIEhum2Yz8372C8tDH4 EKMAB6MSD+8Gj7lRQqyJZcWVuYcYJTiYlUR4I/TnRQnxpiRWVqUW5ccXleakFh9ilOZgURLn PW9QGSUkkJ5YkpqdmlqQWgSTZeLglGpgnMz9/rTGm9g9v5W9e7MS3myUd2C8lVZRdd+pO2BT jvH+tdpt79r0p/F+PcSy0LeD56tpw+R1lanF4p9OanD8E2BpVTd9s0hlqcn90kntWZvfcvbx M3pqFfyNnblBl+F7Sl3Ju6B3ci7/pFuLT1QlyB5/9Ojl9uuP41s3zJgpy2Azu+FxWdImJZbi jERDLeai4kQAp7laxU8CAAA= X-CMS-MailID: 20180306114512eucas1p286d36bafa1bc719d7e7ccbaa9f549fc1 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180306114512eucas1p286d36bafa1bc719d7e7ccbaa9f549fc1 X-RootMTR: 20180306114512eucas1p286d36bafa1bc719d7e7ccbaa9f549fc1 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->digest 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 --- 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..e97c2e662d6a 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->digest. * @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->digest. * @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->digest. * @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->digest. * @halg: see struct hash_alg_common */ struct ahash_alg { -- 2.16.2