Received: by 10.223.185.116 with SMTP id b49csp4192632wrg; Mon, 26 Feb 2018 12:56:11 -0800 (PST) X-Google-Smtp-Source: AH8x2250x/ZZ+kxp5U5tdz1NoUb/cfJoG4CpJViJcoSWxcUPy27R5NbgQ2QZNDAwYQ7HpiRDNq06 X-Received: by 10.98.149.90 with SMTP id p87mr11763722pfd.28.1519678571748; Mon, 26 Feb 2018 12:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519678571; cv=none; d=google.com; s=arc-20160816; b=0RzKMdRjCGAL9WffW5P5M19MQCxoDAXpOlIDAXO0Opnvdn7lSB3DSo+eMzr2XHYBzp 1+UV0k+d2y9J+n0xWU7OfQiLYDrLcN1M/j0rUdnDQ4aOs8MJKAX5psEA9R7aiBDqxxtU NJs2+SvKkJt6KmyGqrzMzVlGsHUmWPjxLYi9HOQt7/fAKHAIa6NLeaQaEarmAYIoT609 J6ew8QIYRuqLIIVH/cHkatD2O2l49I4nzV5wCuIJyqvaqVyeD9Udux8v+y47YjGXSiAI Tj2OgyjLe5WoJmp1h0eAKa2cvsW2a9v5qenHuS3EIhlh0cXzmsZghFtfNGUHQubs3dsO 723Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nj1OrQlk2uBQaaL/wX9hqhFZW7qeyUjjpseHtEYadNo=; b=FrjEZTnbTs6aH73FJCqMdrblWHVvgDxqxK49egET99H10HjQuouvx6WWSXfORkr400 xnVsDa7IGSjcONtzNh0vtoJcYLBd99zEihRsD8TvxjeT4628mw33RXZYdAsO8kc0whz5 W22EoFbotcdymNrUV3HZsaj4AS45tuS8kmoKILXXZCQLYQJOKmJXsmuP0VCVsFhE8dpX I4tylr/Y5g3uim3xfHMPgWI1k2OCflK5ZMGsY5gdhSAAB2B8INGP7o/7ZCnd6LCszqCn evDbV3R2Up4zKZV/Hik/kWp/KFeAvKFtxQglP/M7dQwbq+0dbUB8NSEunoo1LcuuIMxm +s8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11-v6si7483285plk.720.2018.02.26.12.55.55; Mon, 26 Feb 2018 12:56:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681AbeBZUXc (ORCPT + 99 others); Mon, 26 Feb 2018 15:23:32 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34810 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbeBZUX3 (ORCPT ); Mon, 26 Feb 2018 15:23:29 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 13219EC2; Mon, 26 Feb 2018 20:23:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , David Howells Subject: [PATCH 4.14 14/54] PKCS#7: fix certificate blacklisting Date: Mon, 26 Feb 2018 21:21:51 +0100 Message-Id: <20180226202145.084527004@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202144.375869933@linuxfoundation.org> References: <20180226202144.375869933@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 29f4a67c17e19314b7d74b8569be935e6c7edf50 upstream. If there is a blacklisted certificate in a SignerInfo's certificate chain, then pkcs7_verify_sig_chain() sets sinfo->blacklisted and returns 0. But, pkcs7_verify() fails to handle this case appropriately, as it actually continues on to the line 'actual_ret = 0;', indicating that the SignerInfo has passed verification. Consequently, PKCS#7 signature verification ignores the certificate blacklist. Fix this by not considering blacklisted SignerInfos to have passed verification. Also fix the function comment with regards to when 0 is returned. Fixes: 03bb79315ddc ("PKCS#7: Handle blacklisted certificates") Cc: # v4.12+ Signed-off-by: Eric Biggers Signed-off-by: David Howells Signed-off-by: Greg Kroah-Hartman --- crypto/asymmetric_keys/pkcs7_verify.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/crypto/asymmetric_keys/pkcs7_verify.c +++ b/crypto/asymmetric_keys/pkcs7_verify.c @@ -369,8 +369,7 @@ static int pkcs7_verify_one(struct pkcs7 * * (*) -EBADMSG if some part of the message was invalid, or: * - * (*) 0 if no signature chains were found to be blacklisted or to contain - * unsupported crypto, or: + * (*) 0 if a signature chain passed verification, or: * * (*) -EKEYREJECTED if a blacklisted key was encountered, or: * @@ -426,8 +425,11 @@ int pkcs7_verify(struct pkcs7_message *p for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { ret = pkcs7_verify_one(pkcs7, sinfo); - if (sinfo->blacklisted && actual_ret == -ENOPKG) - actual_ret = -EKEYREJECTED; + if (sinfo->blacklisted) { + if (actual_ret == -ENOPKG) + actual_ret = -EKEYREJECTED; + continue; + } if (ret < 0) { if (ret == -ENOPKG) { sinfo->unsupported_crypto = true;