From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755301AbeASKxy (ORCPT ); Fri, 19 Jan 2018 05:53:54 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:40896 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754860AbeASKxc (ORCPT ); Fri, 19 Jan 2018 05:53:32 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180119105329euoutp01e8289871a5b94ea8d863142a26098d37~LMKrSJoK31015110151euoutp01q X-AuditID: cbfec7f2-f793b6d000003243-2a-5a61ce280b8c Subject: Re: [PATCH 5/5] crypto: ahash.c: Require export/import in ahash To: Marek Vasut , linux-crypto@vger.kernel.org Cc: "David S. Miller" , Bartlomiej Zolnierkiewicz , Fabio Estevam , Shawn Guo , Tom Lendacky , Jan Engelhardt , Arvind Yadav , Linus Walleij , Joakim Bech , linux-kernel@vger.kernel.org, Herbert Xu From: Kamil Konieczny Message-id: <4099d611-ccc6-6097-9d4a-99b2306a26e5@partner.samsung.com> Date: Fri, 19 Jan 2018 11:53:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-version: 1.0 In-reply-to: <1ac2ca10-7017-7e44-5651-e53a8a613177@denx.de> Content-type: text/plain; charset="utf-8" Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTYRjmO+fs7DhcHKfmm0nGwChhlml4sLILFgf6E4FgI8jRDmo6lR0V lX6YN2xampcuw8K01Jlo2lwqJqaWZqHdvJFOk7by1o8tQUkt3Vngv+d93uf5Hp6Xj8JlIyJv KjYhmdMmqOLlpIQwvVkdUuwfUikPrU8dZkZvPsKZ5ntNIqZiOIdg9DoFUzDvw2TNLWGMvd5C MGVrtRgzbV7FmM8dFSSzmHcdMZbGxzjTV9Yl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KYYtJXLi3 nq2LkYtDSGAJo8SOru1MEM4zRonN+1czglQJC3hIXNqzggnEFhGwlWjasoMFpIhZ4BSzxIar 15lBEkICn5gk/l2TBrHZBMwlHm0/A9bAK+Am8WDrAXYQm0VAVaLnzz0WEFtUIEKiaeZcVoga QYkfkyHinALWEq/v/ATq5QBaoC4xZUouSJhZQFyiufUmC4QtL7F5zVvmCYyCs5B0z0LomIWk YxaSjgWMLKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzECY2/bsZ9bdjB2vQs+xCjAwajEw7th cUKUEGtiWXFl7iFGCQ5mJRHed95AId6UxMqq1KL8+KLSnNTiQ4zSHCxK4ry9e1ZHCgmkJ5ak ZqemFqQWwWSZODilGhj9nOROMu16PnH2YkmmrmU9OaqnP5kUORr39zvsnKEuyc8279KpA/wZ QktO+Z5SEOpL4lJ1zPgvfO3ok6SUJ8W57nUO76abmanLn3iePsu/6ZHOzB7+wtnCj7kW3Vzx vjuk4ZH0wmWlvHKvdZalJ+26+WwHo0e3Nody5DTbH/tD3AOsTAQTpiixFGckGmoxFxUnAgAg aTbKuQIAAA== X-CMS-MailID: 20180119105328eucas1p18fbfa8331718d782d1448c0b508c4478 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180118183441eucas1p2ee3f046a594945299ea7b75ffb13e2ca X-RootMTR: 20180118183441eucas1p2ee3f046a594945299ea7b75ffb13e2ca References: <20180118183404.12583-1-k.konieczny@partner.samsung.com> <20180118183404.12583-6-k.konieczny@partner.samsung.com> <5db6f843-cc51-09f2-f388-8dade440c6bc@denx.de> <9246bbcb-6cd0-8bc9-8286-02c44e6d01bc@partner.samsung.com> <1ac2ca10-7017-7e44-5651-e53a8a613177@denx.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19.01.2018 11:08, Marek Vasut wrote: > On 01/19/2018 10:53 AM, Kamil Konieczny wrote: >> On 18.01.2018 22:31, Marek Vasut wrote: >>> On 01/18/2018 07:34 PM, Kamil Konieczny wrote: >>>> Export and import are mandatory in async hash. As drivers were >>>> rewritten, drop empty wrappers and correct init of ahash transformation. >>> >>> Are you moving checks from the core subsystem to drivers ? This looks >>> really nonsensical and the commit message doesn't explain the rationale >>> for that at all. >> >> I am removing checks from core. Export and import were optional in beginnig >> of crypto framework, but as time goes on they become mandatory. > > Seems like if the driver doesn't implement those, the core can easily > detect that and perform the necessary action. Moving the checks out of > core seems like the wrong thing to do, rather you should enhance the > checks in core if they're insufficient in my opinion. I removed all checks. No checks in driver and no checks in crypto framework. If you would like any check, I think the place to add them is in ahash alg registraction, in function ahash_prepare_alg add something like: if ((alg->init == NULL) || (alg->digest == NULL) || (alg->final == NULL) || (alg->update == NULL) || (alg->export == NULL) || (alg->import == NULL)) return -EINVAL; The only downsize is this will be usefull in backport (to prevent NULL dereference), as any new driver will have all those pointers sets. >>>> Signed-off-by: Kamil Konieczny >>>> --- >>>> crypto/ahash.c | 18 ++---------------- >>>> 1 file changed, 2 insertions(+), 16 deletions(-) >>>> >>>> diff --git a/crypto/ahash.c b/crypto/ahash.c >>>> index 3a35d67de7d9..c3cce508c1d4 100644 >>>> --- a/crypto/ahash.c >>>> +++ b/crypto/ahash.c >>>> @@ -434,16 +434,6 @@ static int ahash_def_finup(struct ahash_request *req) >>>> return ahash_def_finup_finish1(req, err); >>>> } >>>> >>>> -static int ahash_no_export(struct ahash_request *req, void *out) >>>> -{ >>>> - return -ENOSYS; >>>> -} >>>> - >>>> -static int ahash_no_import(struct ahash_request *req, const void *in) >>>> -{ >>>> - return -ENOSYS; >>>> -} >>>> - >>>> static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) >>>> { >>>> struct crypto_ahash *hash = __crypto_ahash_cast(tfm); >>>> @@ -451,8 +441,6 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) >>>> >>>> hash->setkey = ahash_nosetkey; >>>> hash->has_setkey = false; >>>> - hash->export = ahash_no_export; >>>> - hash->import = ahash_no_import; >>>> >>>> if (tfm->__crt_alg->cra_type != &crypto_ahash_type) >>>> return crypto_init_shash_ops_async(tfm); >>>> @@ -462,15 +450,13 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) >>>> hash->final = alg->final; >>>> hash->finup = alg->finup ?: ahash_def_finup; >>>> hash->digest = alg->digest; >>>> + hash->export = alg->export; >>>> + hash->import = alg->import; >>>> >>>> if (alg->setkey) { >>>> hash->setkey = alg->setkey; >>>> hash->has_setkey = true; >>>> } >>>> - if (alg->export) >>>> - hash->export = alg->export; >>>> - if (alg->import) >>>> - hash->import = alg->import; >>>> >>>> return 0; >>>> } >>>> >>> >>> >> > > -- Best regards, Kamil Konieczny Samsung R&D Institute Poland