Received: by 10.223.185.116 with SMTP id b49csp302885wrg; Fri, 2 Mar 2018 19:46:22 -0800 (PST) X-Google-Smtp-Source: AG47ELv/ia6cAzhScuq1ZG/RS7soCGPzG8LKOXmbZNXPSLm7hY2JdSzZOVJELjMFnujZcqLWV+cK X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr7202535pld.219.1520048782383; Fri, 02 Mar 2018 19:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520048782; cv=none; d=google.com; s=arc-20160816; b=fuLR3SrgaNlNhndYBuzQnjPBpxgHBP4SsQJEN40Dq+uSo3SNZO06ZYNzQP3k3i9OCx 9/GFPd4cHL+wqGOO/jqRkaGazdP8Or574CEbOaPw3vJe4Ycm2c7Iu1dfkK24hRoJMIuO hTO8BgO906Fx9hT+wL3ZEMHJluL92Wdq8w32U/1kKywRf3vqzHuUMw0BMjRNsQRkssn/ suzB4MbvCDi9bb55D8CyDig3NJN29xblVQCPYGPINMjsE9LFWb8F0y0aC4GUHv2p/3+h /mRGiKYuzY+GkbfxRO1yTOQ2uZ0lDHRujbqyNTDnYw0H0fhl+MIypMZFP2zXHJeSY9Mh 72Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=9aaJjJNnqg4t0uZ8DpD92DBlaop6UjLrDfKuYEE/RAU=; b=IuUGzQwLCjiWnWU9Bj9G8hieUj1cIX7m5FJoa3ua2j0W2kXs2IFsNWbE+AM+z7+IuB 806WgIuPxSTlE2P9mYR7qyeoARhhui0qzOfoL5CGCSwVWAiE7HoXXsZVmfrhuRbhny34 Bks5RibuzplDCLcpADRtX0sbUxnYlDfD4ZG03QcPonOrxRO1YQUXXmacKvg/fxre2TBx DDf8BlGoRfPpS9IWYFK8fliGPmfB3YLc5ARJ5bhdhe3+CbsH9PF8c/Y3nKUCslZEXiMI Fpr5tZ6qvNQuz0eG4ZKngxIK/O1MArqqq3qFUySSsdPpm6h+k4an2xhDKOzY+X9aj7Bj OsSg== 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 m61-v6si5864239plb.500.2018.03.02.19.46.08; Fri, 02 Mar 2018 19:46:22 -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 S932486AbeCBXPa (ORCPT + 99 others); Fri, 2 Mar 2018 18:15:30 -0500 Received: from vps-vb.mhejs.net ([37.28.154.113]:59754 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934228AbeCBXP3 (ORCPT ); Fri, 2 Mar 2018 18:15:29 -0500 Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1erttZ-0003BJ-2i; Sat, 03 Mar 2018 00:15:21 +0100 Subject: Re: [PATCH 2/3] crypto: ccp - return an actual key size from RSA max_size callback To: Herbert Xu Cc: "David S. Miller" , David Howells , Tom Lendacky , Gary Hook , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org References: <51c265e4-6153-3e5e-316a-ebef059ac36a@maciej.szmigiero.name> <20180302164451.GJ21579@gondor.apana.org.au> From: "Maciej S. Szmigiero" Message-ID: <087e7b27-f839-8d4b-8da8-5d0fa2f8caf1@maciej.szmigiero.name> Date: Sat, 3 Mar 2018 00:15:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180302164451.GJ21579@gondor.apana.org.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02.03.2018 17:44, Herbert Xu wrote: > On Sat, Feb 24, 2018 at 05:03:21PM +0100, Maciej S. Szmigiero wrote: >> rsa-pkcs1pad uses a value returned from a RSA implementation max_size >> callback as a size of an input buffer passed to the RSA implementation for >> encrypt and sign operations. >> >> CCP RSA implementation uses a hardware input buffer which size depends only >> on the current RSA key length, so it should return this key length in >> the max_size callback, too. >> This also matches what the kernel software RSA implementation does. >> >> Previously, the value returned from this callback was always the maximum >> RSA key size the CCP hardware supports. >> This resulted in this huge buffer being passed by rsa-pkcs1pad to CCP even >> for smaller key sizes and then in a buffer overflow when ccp_run_rsa_cmd() >> tried to copy this large input buffer into a RSA key length-sized hardware >> input buffer. >> >> Signed-off-by: Maciej S. Szmigiero >> Fixes: ceeec0afd684 ("crypto: ccp - Add support for RSA on the CCP") >> Cc: stable@vger.kernel.org > > Patch applied. Thanks. Thanks. However, what about the first patch from this series? Without it, while it no longer should cause a buffer overflow, in-kernel X.509 certificate verification will still fail with CCP driver loaded (since CCP RSA implementation has a higher priority than the software RSA implementation). Maciej