Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp170140imm; Tue, 18 Sep 2018 19:12:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaWPA4jRkux9JXsgw3dRDpfZlBvajF98mKVT+Y1XyNY+nTMywGrNBhTMbDVOvEM+/y69gGj X-Received: by 2002:a63:225f:: with SMTP id t31-v6mr29995445pgm.275.1537323164796; Tue, 18 Sep 2018 19:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537323164; cv=none; d=google.com; s=arc-20160816; b=LRtTLW+MK53cRmpHojHiMpfFdjuYto3DJSf2s2liC4mPD6eOnA1DpuxIaVJtfcn2to h8MAYe5WSuTkjiYHPdHX6wa/Q0Ct63Nig22MnT+CLpXQ6MB5RepSyDs9PrgXISNYi5qG 1OdVUhYjFPI7wi8xfHByhGqqRemsyLL5u6+WpViunxKTMNt7aRmaJp2pF8o43UfUre2I VOI3DJd2c2SA077gxU8wHLMM6CoDLajBfHHX8BADJm9DtkjSuHYNXgRBVVlDi6kPIZls 6rXUP/OYvWtturN3HYZAzaNceiHCqcD/HIpdrYfOeGnENr7a4ltMf2TAbeGz7YXpFti8 evkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8oNl/e9uTp41NIGJYGi79JHHDmF9+QFZKwzGixSKESY=; b=zSbBwvdF080jo4+ITqTNuJbmuxFjEXS855NfKlLDHif6spH/q0JDEt9V61xLqROsE0 jqQyCdptifUbtJmkJ+dO8eS4Xk4IQGD+zfXc9wHVxiKcENC/k9QGga1qctlcQNbxuzpi kU01K+0Rrme7qngF3zn4sk88L7p3NNSDjiZvv6Ca8jumJxPuwdZkab1jQM9TZZKAvJLG dvdmyMurx67sv9euwU2205Om0njuLpGrhCbvfy1g6YUgP5wPTgPEWl0jpCLQOGJuFt2l ApFGe95ygFhB+VsY8IlIPvXH+c58pw/RwPpPcBTQ3RLfmdWoIIo7l6ZoK4pYQ4O4AzpL WAoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CunrNz7O; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k190-v6si19091669pgd.80.2018.09.18.19.12.29; Tue, 18 Sep 2018 19:12:44 -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=@chromium.org header.s=google header.b=CunrNz7O; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730842AbeISHr0 (ORCPT + 99 others); Wed, 19 Sep 2018 03:47:26 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36630 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730967AbeISHqq (ORCPT ); Wed, 19 Sep 2018 03:46:46 -0400 Received: by mail-pf1-f194.google.com with SMTP id b11-v6so1919724pfo.3 for ; Tue, 18 Sep 2018 19:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8oNl/e9uTp41NIGJYGi79JHHDmF9+QFZKwzGixSKESY=; b=CunrNz7OuS/C/Vor9xnjWZnofRwOJg3CbCmk4yez1Yjn5gXxf2JQulpUX4y8NV3+en YgTa8mclnxwt5btJdIqlrKkMsk8aa8WlKOhw2USQFp51+oyU4hpospC3J1cyRI/CT9YR YHb1YZhJCeaE7VB5dVJmnjPpXzcK5GVfnMV2A= 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:in-reply-to :references; bh=8oNl/e9uTp41NIGJYGi79JHHDmF9+QFZKwzGixSKESY=; b=Sl6khSRLTfuwOTo6Iz9rbdTaOjYy0RcB/ah0vYV7UJ5DpGhlN6sFpXD6w0D4/LoTeX z8bd+xOF+QDX+2MTXOpJc/hL1swtOw/Mm4CAex7Y/YaR42/xg5Y4rArxST95xANz2RZA jK4PPqckXr9pW4CsXF07obEzhzFswhrILtW+fm5fsAaM2bgzvycCbu4Ku/r1bU9oNTY+ Ll/B2pet9FSIb7qe9zGooHS/93faO8QUGSc+51TuKVNtXfUQ7dlspbDlAdR9WFn2RyhO 3In8cuSckFpL5Y5MzkfEvOqjgkE7LsG7sZmJwMs9uIiUcW2Wx5+hDBK9z2QW9k0R2N8f fiMQ== X-Gm-Message-State: APzg51BVlG1b+BwFt8Nu/gdQUK43iz1D2+cedaiJ305JILe2EUn3LDi/ wjdPTEMNlyaOal+fKbFAJG61kQ== X-Received: by 2002:a62:1d54:: with SMTP id d81-v6mr33652235pfd.139.1537323078902; Tue, 18 Sep 2018 19:11:18 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id y7-v6sm25063370pge.8.2018.09.18.19.11.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Sep 2018 19:11:17 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , Greg Kroah-Hartman , Felipe Balbi , Johan Hovold , "Gustavo A. R. Silva" , linux-usb@vger.kernel.org, Ard Biesheuvel , Eric Biggers , linux-crypto , Linux Kernel Mailing List Subject: [PATCH crypto-next 11/23] wusb: Remove VLA usage of skcipher Date: Tue, 18 Sep 2018 19:10:48 -0700 Message-Id: <20180919021100.3380-12-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180919021100.3380-1-keescook@chromium.org> References: <20180919021100.3380-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the quest to remove all stack VLA usage from the kernel[1], this replaces struct crypto_skcipher and SKCIPHER_REQUEST_ON_STACK() usage with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(), which uses a fixed stack size. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Cc: Greg Kroah-Hartman Cc: Felipe Balbi Cc: Johan Hovold Cc: "Gustavo A. R. Silva" Cc: linux-usb@vger.kernel.org Signed-off-by: Kees Cook --- drivers/usb/wusbcore/crypto.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c index aff50eb09ca9..68ddee86a886 100644 --- a/drivers/usb/wusbcore/crypto.c +++ b/drivers/usb/wusbcore/crypto.c @@ -189,7 +189,7 @@ struct wusb_mac_scratch { * NOTE: blen is not aligned to a block size, we'll pad zeros, that's * what sg[4] is for. Maybe there is a smarter way to do this. */ -static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, +static int wusb_ccm_mac(struct crypto_sync_skcipher *tfm_cbc, struct crypto_cipher *tfm_aes, struct wusb_mac_scratch *scratch, void *mic, @@ -198,7 +198,7 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, size_t blen) { int result = 0; - SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc); + SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc); struct scatterlist sg[4], sg_dst; void *dst_buf; size_t dst_size; @@ -224,7 +224,7 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, if (!dst_buf) goto error_dst_buf; - iv = kzalloc(crypto_skcipher_ivsize(tfm_cbc), GFP_KERNEL); + iv = kzalloc(crypto_sync_skcipher_ivsize(tfm_cbc), GFP_KERNEL); if (!iv) goto error_iv; @@ -251,7 +251,7 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, sg_set_page(&sg[3], ZERO_PAGE(0), zero_padding, 0); sg_init_one(&sg_dst, dst_buf, dst_size); - skcipher_request_set_tfm(req, tfm_cbc); + skcipher_request_set_sync_tfm(req, tfm_cbc); skcipher_request_set_callback(req, 0, NULL, NULL); skcipher_request_set_crypt(req, sg, &sg_dst, dst_size, iv); result = crypto_skcipher_encrypt(req); @@ -298,19 +298,19 @@ ssize_t wusb_prf(void *out, size_t out_size, { ssize_t result, bytes = 0, bitr; struct aes_ccm_nonce n = *_n; - struct crypto_skcipher *tfm_cbc; + struct crypto_sync_skcipher *tfm_cbc; struct crypto_cipher *tfm_aes; struct wusb_mac_scratch *scratch; u64 sfn = 0; __le64 sfn_le; - tfm_cbc = crypto_alloc_skcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC); + tfm_cbc = crypto_alloc_sync_skcipher("cbc(aes)", 0, 0); if (IS_ERR(tfm_cbc)) { result = PTR_ERR(tfm_cbc); printk(KERN_ERR "E: can't load CBC(AES): %d\n", (int)result); goto error_alloc_cbc; } - result = crypto_skcipher_setkey(tfm_cbc, key, 16); + result = crypto_sync_skcipher_setkey(tfm_cbc, key, 16); if (result < 0) { printk(KERN_ERR "E: can't set CBC key: %d\n", (int)result); goto error_setkey_cbc; @@ -351,7 +351,7 @@ ssize_t wusb_prf(void *out, size_t out_size, crypto_free_cipher(tfm_aes); error_alloc_aes: error_setkey_cbc: - crypto_free_skcipher(tfm_cbc); + crypto_free_sync_skcipher(tfm_cbc); error_alloc_cbc: return result; } -- 2.17.1