From patchwork Sun Jun 11 21:20:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 9780199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C40B60352 for ; Sun, 11 Jun 2017 21:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83A7128435 for ; Sun, 11 Jun 2017 21:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 763C12843B; Sun, 11 Jun 2017 21:20:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 124CA28435 for ; Sun, 11 Jun 2017 21:20:50 +0000 (UTC) Received: (qmail 16167 invoked by uid 550); 11 Jun 2017 21:20:49 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 16129 invoked from network); 11 Jun 2017 21:20:47 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=mail; bh=tmtzLMwIUDCD tDvfJiIiQo3i9xs=; b=FYblN6tq8Y+CTSURY6gKkk7bZVJ3/cVnOJLOXFDvuJLW Nsqe2DhiovmDLlrB1QI47geDvJNW2kWup0CtrKjxu9MdVm+KofUCI6tGiCANRIV6 xdDp7CWPlCG2Gl99oU8Wq0NoXad6pW6pG1YkLzoumwttl0yiYBjC1JQDLDSJbtbU mrQAGs/1U0WUMe8r/ihO988BQiqYIOpDE0feMy7CXmrlxYiYCQjO/PpqmOrcG/c6 ZSLLPGPxT9iASRQ/aFItVds4rorHmowDBhvCbtSss0p3TytcwitjPaIxiRzJj9dw 9AzyiZB86OItvnkCHoTYLzHlyYa/Wwhru9ozhxaDkw== From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: "Jason A. Donenfeld" , stable@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org Date: Sun, 11 Jun 2017 23:20:23 +0200 Message-Id: <20170611212023.31101-1-Jason@zx2c4.com> In-Reply-To: <20170610025912.6499-1-Jason@zx2c4.com> References: <20170610025912.6499-1-Jason@zx2c4.com> MIME-Version: 1.0 Subject: [kernel-hardening] [PATCH] rsa-pkcs1pad: use constant time memory comparison for MACs X-Virus-Scanned: ClamAV using ClamSMTP Otherwise, we enable all sorts of forgeries via timing attack. Signed-off-by: Jason A. Donenfeld Suggested-by: Stephan Müller Cc: stable@vger.kernel.org Cc: Herbert Xu Cc: linux-crypto@vger.kernel.org --- crypto/rsa-pkcs1pad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 8baab4307f7b..7830d304dff6 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -496,7 +496,7 @@ static int pkcs1pad_verify_complete(struct akcipher_request *req, int err) goto done; pos++; - if (memcmp(out_buf + pos, digest_info->data, digest_info->size)) + if (crypto_memneq(out_buf + pos, digest_info->data, digest_info->size)) goto done; pos += digest_info->size;