Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp49829pxb; Tue, 12 Jan 2021 19:43:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyA49S8fi25JHuJL8w/ylZ8v5t1JP+CtK8YGfjXMw5EBarIndXfpZBm8cQ6OThepymY41/ X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr75534ejo.479.1610509392454; Tue, 12 Jan 2021 19:43:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610509392; cv=none; d=google.com; s=arc-20160816; b=KcckMhXet/xruIXYV2fjuKLfxGXr6zqeG0GZRJg9AgAY40Ht8LBxB8tpcQg8isLUnM +2ef1Dut03SmIgfLK9wLilHSuuCSvTEwFp/Cl/b4xXl/AlcNHOGnmVJclbhY6zdEzEov K1kx2GKFVP7bU5W/Q6PAkrdD6wir4ZejjbV/X90GRvH292zrv8/LSNJOmYLHhjL7Sagn apal90Dzdi/phNSoMOIohtQ6k0iX4e8B7ohYwMKlcOrbzmqIDh/QJ3bghXzo7l78yQUY O+E6GoF5S2XD2nYN4+FUVTb6R51t6lGZXK7qdBs83MJGDjq3RLHTd2xYevdm2geu/fOc tV0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ru8uHDoup63rPbSw7L3qTpGazA8YV05+r/mkYguv/js=; b=zwQq+7obUCIbwkvO+A9MuDqMgMFTGOs0aHdDbD8d4Z08voqSQYS8pbEViXDBZhiN0K oxYVBUeBK3wXLMdcqHAYTF7KwXi82dTeo/byOKbCjunyzTZMIb+BCtfrGQSRhbaJ1iuK v9BBQVBwYNJAYC9IGXTVDy3wlqHtGR8NEKmrPADhteRWYLgjlUEAL6Vnl5DQ2vhFmSmx 5G6BQZCiYD0lih0Fd48zG5nCf718oxY7R8TdnAfe24OYYj7g8M3H14jNmHhNQdBAh+Ot 9Kl200PGL91qKEF/dvsVDSWQY7xIp24rl0yBjgq+JYfMZOJiUQfOde3drzGrV39rMs+2 yNoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b27si268555eje.466.2021.01.12.19.42.52; Tue, 12 Jan 2021 19:43:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbhAMCkA (ORCPT + 99 others); Tue, 12 Jan 2021 21:40:00 -0500 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:54024 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbhAMCkA (ORCPT ); Tue, 12 Jan 2021 21:40:00 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0ULZwVnh_1610505555; Received: from B-455UMD6M-2027.local(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0ULZwVnh_1610505555) by smtp.aliyun-inc.com(127.0.0.1); Wed, 13 Jan 2021 10:39:16 +0800 Subject: Re: [PATCH] crypto: public_key: check that pkey_algo is non-NULL before passing it to strcmp() To: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , David Howells , Herbert Xu , "David S. Miller" Cc: Gilad Ben-Yossef , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, stable@vger.kernel.org References: <20210112161044.3101-1-toke@redhat.com> From: Tianjia Zhang Message-ID: Date: Wed, 13 Jan 2021 10:39:15 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210112161044.3101-1-toke@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi, I have fixed this problem last week. Still thanks for your fixing. patch is here: https://lkml.org/lkml/2021/1/7/201 Best regards, Tianjia On 1/13/21 12:10 AM, Toke Høiland-Jørgensen wrote: > When public_key_verify_signature() is called from > asymmetric_key_verify_signature(), the pkey_algo field of struct > public_key_signature will be NULL, which causes a NULL pointer dereference > in the strcmp() check. Fix this by adding a NULL check. > > One visible manifestation of this is that userspace programs (such as the > 'iwd' WiFi daemon) will be killed when trying to verify a TLS key using the > keyctl(2) interface. > > Cc: stable@vger.kernel.org > Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification") > Signed-off-by: Toke Høiland-Jørgensen > --- > crypto/asymmetric_keys/public_key.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c > index 8892908ad58c..35b09e95a870 100644 > --- a/crypto/asymmetric_keys/public_key.c > +++ b/crypto/asymmetric_keys/public_key.c > @@ -356,7 +356,7 @@ int public_key_verify_signature(const struct public_key *pkey, > if (ret) > goto error_free_key; > > - if (strcmp(sig->pkey_algo, "sm2") == 0 && sig->data_size) { > + if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 && sig->data_size) { > ret = cert_sig_digest_update(sig, tfm); > if (ret) > goto error_free_key; >