From patchwork Sat Jun 10 02:59:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 9779639 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 4062260393 for ; Sat, 10 Jun 2017 03:01:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30D0C286A8 for ; Sat, 10 Jun 2017 03:01:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 239A3286B7; Sat, 10 Jun 2017 03:01:14 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A09C2286A8 for ; Sat, 10 Jun 2017 03:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822AbdFJC71 (ORCPT ); Fri, 9 Jun 2017 22:59:27 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:52679 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676AbdFJC7Z (ORCPT ); Fri, 9 Jun 2017 22:59:25 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 67bde4d2; Sat, 10 Jun 2017 02:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=mail; bh=9PiH 7cCY5kMrzUnQlfizwIG4g1w=; b=qAHCTUUazzkT7/i9Tj72Wjvrq31TPZzZTkN2 JG9fkGWoLIFZPL/ccctxAVVjDloO3jSI3yOYx1X/SxBvRGP9Zj1hXvYTO3hEkgvG s6Xr0UiwFsifuyE40bHwHaocbb6f+PG7n35OyU4rZcRad/PbQuqTayhXAl12OUyv dadYEdgBTW5lk9suQLc7VgQdf6MJd3UgRAQifGKAwFA03gREC3HtQADwoseBRkUR Io6w89XxlmYHGVJrrgEm9m2iOA2KCjn/KytFNLkLc4o0Qev5Xo4Ockqy8laegGqF cwAl170E5ovWAmNis8EGFJhDpAjCiHCDb3CVjX93lcjFETKy2Q== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id b47e3422 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Sat, 10 Jun 2017 02:58:37 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: "Jason A. Donenfeld" , "J. Bruce Fields" , Jeff Layton , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/6] sunrpc: use constant time memory comparison for mac Date: Sat, 10 Jun 2017 04:59:07 +0200 Message-Id: <20170610025912.6499-2-Jason@zx2c4.com> In-Reply-To: <20170610025912.6499-1-Jason@zx2c4.com> References: <20170610025912.6499-1-Jason@zx2c4.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Otherwise, we enable a MAC forgery via timing attack. Signed-off-by: Jason A. Donenfeld Cc: "J. Bruce Fields" Cc: Jeff Layton Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org Cc: stable@vger.kernel.org --- net/sunrpc/auth_gss/gss_krb5_crypto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index fb39284ec174..12649c9fedab 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c @@ -34,6 +34,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include #include #include @@ -927,7 +928,7 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf, if (ret) goto out_err; - if (memcmp(pkt_hmac, our_hmac, kctx->gk5e->cksumlength) != 0) { + if (crypto_memneq(pkt_hmac, our_hmac, kctx->gk5e->cksumlength) != 0) { ret = GSS_S_BAD_SIG; goto out_err; }