Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2691889ybi; Mon, 1 Jul 2019 17:03:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJmEFmkfruuw9g7WrWm6Gkwih1/A0yXO1E/atWisNa3FDSejLP2PQwYE68SMe5yI3M2j3m X-Received: by 2002:a17:902:a516:: with SMTP id s22mr31153132plq.178.1562025789184; Mon, 01 Jul 2019 17:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562025789; cv=none; d=google.com; s=arc-20160816; b=k2jFGJotsWE/lBonYiORhQbB/cKgU0XJqJye+go8lJbUAOg8LCao2BqD70+WPdIDux gqG/GQbyKc+npJCN+d6IwSSh0tVT0OdELU/DOGiuereOueGgJ69ACVPX5APTpugteI+o dYtZa8KYeWesOMKkBiBI1pyVDft2ffJzE16NdSz/SguvPRgupwBvidzX4hlf0bacevCg aZQ2MOfgp5Jvh1ddNERZfzWxhRXnq9akK0DwQ+CZjAnUmas0Jxfekm2JBHrWW8l+3jxk z6VIZODaxPyLSUXL4joH1trN/Zhw0h6cxl1btCfVedsrTcOQpNPMpDrVaDqmokMzgMsS ky/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=14MOM6ICngoLLgb1hrf/bM8O+6Uy5LcBnEPwLhZGisA=; b=AXzqGJ3YiRkH7MCJqjyZD/pIEDyejV0yj8sAAFbCWmA+7UfcT5mle5xUE8OLP3ab0u dLY5BsTzk4nfLtIN1k+qSBJW0LC9rDWEF2rg+sDPh8knMypkz2QHSWJ9Gvpk2tzPfADo 7qmtYv8s1IYvDZE7utGGx1ay/EBs+6zRhHaP+cFh8HT6mEYws17/xCFW8xR7UYeDYfHW k2o/kDUZfA/vQMy1ZjyGc0Jf8++2fmC1XLPbt1AKD6YoA9gWjobvdfc08EXMCLW+qItX zMti4N/Jk3v6OsNJBRBOqov3Gq6NYA8eEUdA2/6NAdMzC/jfud5g+7dAmrXeEP+iqgZ2 abNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ab0ZyOF0; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32si11260887pld.252.2019.07.01.17.02.54; Mon, 01 Jul 2019 17:03:09 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=ab0ZyOF0; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727055AbfGBAC1 (ORCPT + 99 others); Mon, 1 Jul 2019 20:02:27 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:39160 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726966AbfGBAC1 (ORCPT ); Mon, 1 Jul 2019 20:02:27 -0400 Received: by mail-qk1-f202.google.com with SMTP id j17so7488779qki.6 for ; Mon, 01 Jul 2019 17:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=14MOM6ICngoLLgb1hrf/bM8O+6Uy5LcBnEPwLhZGisA=; b=ab0ZyOF0ZZkkQMOBm16TGGEeQFK/jjtvGf3wEx27RMnXQxrDBNdaJYXoBBeGr5LnO2 yCn6V8eE+fGZvJcjh8XYGMVFt8fgkv2h31llQxIwD0pszH2nCXpm4pmE/yAxWGiqducr Um/F4GZ5f+4xXzJnSDUyhYRr75CeDapfZf+W+E6QIIIEcvN/2bmVLsbnDVtTg92I11bF Xvi2CyLVmX4o/fXUISIVyJFG0yhus80Kd98bDgXNFc08pLguDIzHn40en5csghrqJdP/ CoVBUT6A1KZCzgFSRU9yuIebcKq6qj/wydhx0jBqZEIurcaCWB5wcib9YZTFizzNAgmw Kt3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=14MOM6ICngoLLgb1hrf/bM8O+6Uy5LcBnEPwLhZGisA=; b=i30ENDSF7Tj7eMIS1cJHvmfywor7tR7BqwWr7WgwMNczYNh0KkW/O0KwypkBiJApxi Kl/8lpI3il0yLbTrFUsvgjHyy+U81kzWhv/JkK3H3FIPJbGG0uOTBEi5RGVtUlVEhIoi 4nl7oRT8W4TrkscoqxSNClIStSKn/JAVe6Lnry49Uip+6FCmsVaoGdmiajOF5b/ab4FS 0XDCMYA0DNMcaYSreHWcUJdHA7+hQES74ypnsgGRtkkULdoPoMSJSAgkCJV+bjeCjsUS JHr1DsuefWii3oHq5Y0+n6e4gDDzQTbBi/eztAW/7yFJk3ZgtDgMkCExchDOraqkDz2g o0Cg== X-Gm-Message-State: APjAAAUG6GsN3eCPndBjAdt2NtlfvojWoS7W3fhl2IDIBlKOj/WZht3B +6Th4jPqvPlzhCTQdFguDNuaX0pk X-Received: by 2002:aed:38c2:: with SMTP id k60mr21843273qte.83.1562025746390; Mon, 01 Jul 2019 17:02:26 -0700 (PDT) Date: Mon, 1 Jul 2019 17:01:32 -0700 Message-Id: <20190702000132.88836-1-cfir@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH] crypto: ccp/gcm - use const time tag comparison. From: Cfir Cohen To: Tom Lendacky , Gary Hook , Herbert Xu , David Rientjes Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Cfir Cohen 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 Avoid leaking GCM tag through timing side channel. Signed-off-by: Cfir Cohen --- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index db8de89d990f..633670220f6c 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -840,7 +840,8 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, if (ret) goto e_tag; - ret = memcmp(tag.address, final_wa.address, AES_BLOCK_SIZE); + ret = crypto_memneq(tag.address, final_wa.address, + AES_BLOCK_SIZE) ? -EBADMSG : 0; ccp_dm_free(&tag); } -- 2.22.0.410.gd8fdbe21b5-goog