From patchwork Fri Jun 29 00:28:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10495445 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 B413D602B3 for ; Fri, 29 Jun 2018 00:30:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A25B629E3F for ; Fri, 29 Jun 2018 00:30:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9691C29E7A; Fri, 29 Jun 2018 00:30:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 47B7A29E3F for ; Fri, 29 Jun 2018 00:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030326AbeF2A3v (ORCPT ); Thu, 28 Jun 2018 20:29:51 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:45804 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932085AbeF2A2z (ORCPT ); Thu, 28 Jun 2018 20:28:55 -0400 Received: by mail-pg0-f68.google.com with SMTP id z1-v6so3174150pgv.12 for ; Thu, 28 Jun 2018 17:28:55 -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=8YjMcInXJrnMY6NIy0rzHFpjLepbrpMxKQdqxE6spGc=; b=ZACXIEqzUy/qd1XXayCIX39szLzUHtIUUrUSzsEmKCXEC7vKVRlzYERBjpnuFYD8f/ hOZ7W3JhqLeyyg1iOS3L0PXQF9Hce1e0iwT3Kpar7HHE0YqBfk6ytACKlRU/FMrD8rWA 5C+jlgS/D1KjmPC116e8dT1SQzqRGzsBziAR0= 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=8YjMcInXJrnMY6NIy0rzHFpjLepbrpMxKQdqxE6spGc=; b=BfgsYJlORLYoN+j5ZP6ONQUZUa9ORkasJoGUq9ErPe+nmFOq45ynvtzKxszIbvJMsL Pz0At77Tm096PeaU6ocURwO/cjL8K9KmwEC+FoXwlPQgHXz01XXxnYHtUJAiYDtIhvBl nE8WQWZYwU32rgoBIFIS8zGJVy48OusToWst+iXc+ihlROOkE/tx5Nd3OjhQhgRF/T1j uupfRy35XNjC3NpotoCbSWw7sw5eNens7ojCnRxPE5aWz2C+3GwSPN8g0Q0MB1jhQUDu 0iQKHB+ILmM/aggYJhuLdsWqLD16//MEYQfchj+CdmUhNgMGmZhxYTP1/klOBKHjd7O/ 4S9w== X-Gm-Message-State: APt69E0LoVKHTJqVLuE5TjEiJ2/Q9K1lUHdc/ic780qI490fFF37sVL2 VlfwTqxQEiUVPIIjjDwyvkOIlw== X-Google-Smtp-Source: AAOMgpfIlakhyiLXVaIFY8i7TNkl/x4ruDsl4VsPDdERUm9ygm4atD2SZxplz0XFo6uxQczHNIbT0w== X-Received: by 2002:a62:6502:: with SMTP id z2-v6mr12170203pfb.76.1530232134899; Thu, 28 Jun 2018 17:28:54 -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 g25-v6sm2464862pge.52.2018.06.28.17.28.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 17:28:53 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , "Gustavo A. R. Silva" , Arnd Bergmann , Eric Biggers , Alasdair Kergon , Giovanni Cabiddu , Lars Persson , Mike Snitzer , Rabin Vincent , Tim Chen , "David S. Miller" , linux-crypto@vger.kernel.org, qat-linux@intel.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/9] dm verity fec: Remove VLA usage Date: Thu, 28 Jun 2018 17:28:40 -0700 Message-Id: <20180629002843.31095-7-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629002843.31095-1-keescook@chromium.org> References: <20180629002843.31095-1-keescook@chromium.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the quest to remove all stack VLA usage from the kernel[1], this uses the newly defined max digest size macro. Also adds a sanity-check at use-time. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook --- drivers/md/dm-verity-fec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index 684af08d0747..fe5cfd1a5fa5 100644 --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c @@ -212,12 +212,15 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, struct dm_verity_fec_io *fio = fec_io(io); u64 block, ileaved; u8 *bbuf, *rs_block; - u8 want_digest[v->digest_size]; + u8 want_digest[AHASH_MAX_DIGESTSIZE]; unsigned n, k; if (neras) *neras = 0; + if (WARN_ON(v->digest_size > sizeof(want_digest))) + return -EINVAL; + /* * read each of the rsn data blocks that are part of the RS block, and * interleave contents to available bufs