From patchwork Mon Feb 27 15:30:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94556 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp912608qgi; Mon, 27 Feb 2017 07:32:55 -0800 (PST) X-Received: by 10.84.232.9 with SMTP id h9mr25182602plk.102.1488209575766; Mon, 27 Feb 2017 07:32:55 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f68si15439943pff.87.2017.02.27.07.32.55; Mon, 27 Feb 2017 07:32:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@linaro.org; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751837AbdB0Pcy (ORCPT + 1 other); Mon, 27 Feb 2017 10:32:54 -0500 Received: from mail-wr0-f177.google.com ([209.85.128.177]:36552 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751500AbdB0Pcw (ORCPT ); Mon, 27 Feb 2017 10:32:52 -0500 Received: by mail-wr0-f177.google.com with SMTP id u108so24786497wrb.3 for ; Mon, 27 Feb 2017 07:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Ui7SYvKEq43xRPn/iYD6mSs4sW4ZoAHe/1Zxe1diY/E=; b=TqulwVcHBQuwBsNOCqSF+i3cxZs659DaWOIuFTTo/H9kfAhx7igvnxENGHh812ntbM gILPvtCBL8HvytrqEKwUZR7uFZgMRmG3KvGPJoeplNALXBjGZm8FGkKWEd04yGorqIwf 2wcK9ftTmIxMJJLBXZc0LSV6MYoemNShiFplk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ui7SYvKEq43xRPn/iYD6mSs4sW4ZoAHe/1Zxe1diY/E=; b=JsKYRXurWIiOmsw14VgA/R3M79flEcs7GHLhv2HOX/yN8oG6fBy0phmLWddelTcc6K Wx41kKhG0PjkxD2LEF25fR0Wbc6yQH3VxbP4vA+LPgkPEr+YZbkrODG7Z74CTjWFj1LL rRAvbbWNlejL4lvlc3VFCoi4dTZi4u3hp5++MNWUVhFzkm2nK3QKcCSBqjQrmM1dhsHp i2+M2dWV91WfSnQgLv5HZRGSRs51b1spwXKVDB0lF0sXB5Uo145kV9LQBx91HGMT26hS GYGYFgspsor/Ye859ohuPB63+9zhwN+C0m2NSUwp4TU43TdewXg4LcPszow/Od6Qc/9+ yEMw== X-Gm-Message-State: AMke39nsedOSlrK/j4WIECtRDmafVpRcYNcgvPVEP+x5MHPRM37/Dapein/xtoTSC+St81in X-Received: by 10.223.174.26 with SMTP id x26mr15508217wrc.124.1488209472447; Mon, 27 Feb 2017 07:31:12 -0800 (PST) Received: from localhost.localdomain ([105.149.201.216]) by smtp.gmail.com with ESMTPSA id v130sm5048180wmv.2.2017.02.27.07.31.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Feb 2017 07:31:11 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: johannes@sipsolutions.net, Ard Biesheuvel Subject: [PATCH] crypto: ccm - move cbcmac input off the stack Date: Mon, 27 Feb 2017 15:30:56 +0000 Message-Id: <1488209456-7653-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Commit f15f05b0a5de ("crypto: ccm - switch to separate cbcmac driver") refactored the CCM driver to allow separate implementations of the underlying MAC to be provided by a platform. However, in doing so, it moved some data from the linear region to the stack, which violates the SG constraints when the stack is virtually mapped. So move idata/odata back to the request ctx struct, of which we can reasonably expect that it has been allocated using kmalloc() et al. Reported-by: Johannes Berg Fixes: f15f05b0a5de ("crypto: ccm - switch to separate cbcmac driver") Signed-off-by: Ard Biesheuvel --- crypto/ccm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 Tested-by: Johannes Berg diff --git a/crypto/ccm.c b/crypto/ccm.c index 442848807a52..1ce37ae0ce56 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c @@ -45,6 +45,7 @@ struct crypto_rfc4309_req_ctx { struct crypto_ccm_req_priv_ctx { u8 odata[16]; + u8 idata[16]; u8 auth_tag[16]; u32 flags; struct scatterlist src[3]; @@ -183,8 +184,8 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain, AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); unsigned int assoclen = req->assoclen; struct scatterlist sg[3]; - u8 odata[16]; - u8 idata[16]; + u8 *odata = pctx->odata; + u8 *idata = pctx->idata; int ilen, err; /* format control data for input */