Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753372AbdC0XFZ convert rfc822-to-8bit (ORCPT ); Mon, 27 Mar 2017 19:05:25 -0400 Received: from mailout.micron.com ([137.201.242.129]:20420 "EHLO mailout.micron.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752740AbdC0XFX (ORCPT ); Mon, 27 Mar 2017 19:05:23 -0400 From: "Ming Ma (mingma)" To: Herbert Xu CC: "davem@davemloft.net" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 1/1] crypto: If two strings are exact match, they must have same length. Thread-Topic: [PATCH 1/1] crypto: If two strings are exact match, they must have same length. Thread-Index: AQHSoovQgdxu1Twq402IRisenM7+46GgkHcAgAjG8EA= Date: Mon, 27 Mar 2017 23:04:30 +0000 Message-ID: References: <1490132440-112761-1-git-send-email-mingma@micron.com> <20170322030040.GB29214@gondor.apana.org.au> In-Reply-To: <20170322030040.GB29214@gondor.apana.org.au> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [137.201.84.23] x-tm-as-product-ver: SMEX-12.0.0.1464-8.100.1062-22970.003 x-tm-as-result: No--15.664700-0.000000-31 x-tm-as-matchedid: 150567-701625-704425-700685-106230-703782-863828-700648-7 03523-701461-705861-700107-139006-704287-700724-700486-106660-863299-700075 -139010-703788-105640-709397-702358-187306-701604-139630-709251-105250-7080 60-703061-702714-705431-700270-188019-706290-703747-705388-700401-700618-13 9704-702106-148004-148133-20043-42000-42003 x-tm-as-user-approved-sender: Yes x-tm-as-user-blocked-sender: No x-mt-checkinternalsenderrule: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2294 Lines: 52 Please ignore this patch, we have seen some issues in older verison of linux kernel. But it doesn't seem to be an issue in the latest kernel. thanks -----Original Message----- From: linux-crypto-owner@vger.kernel.org [mailto:linux-crypto-owner@vger.kernel.org] On Behalf Of Herbert Xu Sent: Tuesday, March 21, 2017 8:01 PM To: Ming Ma (mingma) Cc: davem@davemloft.net; linux-crypto@vger.kernel.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] crypto: If two strings are exact match, they must have same length. On Tue, Mar 21, 2017 at 04:40:40PM -0500, Ming Ma wrote: > When both "crct10dif-pclmul" algorithm and "crct10dif-generic" > algorithm exist in crypto_alg_list, "crct10dif-pclmul" should be > selected, since it has higher priority than "crct10dif-generic". > However, both algorithms have the same cra_name "crct10dif". If we use > "crct10dif" to find a matched algorithm in crypto_alg_list, it's > possible "crct10dif-generic" is selected, because the code calls > strcmp to decide if two string are exact match, but doesn't check if two strings have the same length. > > exact = !strcmp(q->cra_driver_name, name); > > So ,if "crct10dif-generic" is in front of "crct10dif-pclmul" in > crypto_alg_list, it will be picked as the matched algorithm, even if > it has lower priority than "crct10dif-pclmul". > Signed-off-by: Ming Ma > --- > crypto/api.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/crypto/api.c b/crypto/api.c index b16ce16..5b3d45a 100644 > --- a/crypto/api.c > +++ b/crypto/api.c > @@ -76,7 +76,8 @@ static struct crypto_alg *__crypto_alg_lookup(const char *name, u32 type, > ((struct crypto_larval *)q)->mask != mask) > continue; > > - exact = !strcmp(q->cra_driver_name, name); > + exact = (strlen(name) == strlen(q->cra_driver_name)) && > + !strcmp(q->cra_driver_name, name); > fuzzy = !strcmp(q->cra_name, name); > if (!exact && !(fuzzy && q->cra_priority > best)) > continue; This is bogus. Please describe how you reproduced the problem. The priority matching should work. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt