Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp420656imm; Thu, 28 Jun 2018 23:33:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeKhqBhIPWXcIk9Ve/iveurs896frIEs7JQsGWjRAKhSv4664fHqgka2tqCp7K/mpsDUTQ+ X-Received: by 2002:a62:1d97:: with SMTP id d145-v6mr13308907pfd.101.1530254019106; Thu, 28 Jun 2018 23:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530254019; cv=none; d=google.com; s=arc-20160816; b=DWHt2halUJd0ciP/g+fGauz1Bl7KozNEjx1DTDL2i1+X2c6LvKEFwWocVm61g1WLbt BW/0J2UsKRZijxNK04OCytV0RQfzhk/pyw6B0fxLu6t4xFhPPzL9sFA9QHNv4aMHMLST Cusr0Aoa3zLz8MHKKORs9kRGYmv5JdlxjkSDSqgo+v3YwhEHsR8MB7ioqCWiDhQHX7qU 5/jsxaa294lt8u24O/BPeulK6to9UqCrBQZ2kknN3xbl91fhhO+g1i6CKPyCLsX4tmeb RQep81YEftCAgcwqHjBMoGPtDgM8ttCWEppNuVkgN+HdkogEDsFCRPhylv0SRtPyGlT1 AVIA== 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:arc-authentication-results; bh=8YjMcInXJrnMY6NIy0rzHFpjLepbrpMxKQdqxE6spGc=; b=TCt0yKDZ2duuimb3xv2fUBQ0ogbRlRGCc4gV9veSIoh6wRQbWdeh0dYLnQkNjVb863 bF8IjC+oYDbqdmA+4ZwqdXPvJ35FTCFVqGQsEZOd4G5RhjizTB4DIIp7JwMGGHT70Kj9 JJK2ubI3JM2J8c5jCaf1JqCjDS6G08GXMumlNIGiStSVY5iaRh/JY2AqCAjcdTcELlkX 6TiHG/7dO328nPlh64UhCUlMqm+6HLPmFz+1igqJiQU5U1rQA08kIUbsO8RsIE9hEJai 8RJwlgmLbb0Db1YymYTZaFYnVCbmFZhxCc/SOCPo4xsD44BRsR2ThuswEGGJHRBcHPvA 6v6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZACXIEqz; 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 t10-v6si8147216plh.306.2018.06.28.23.33.24; Thu, 28 Jun 2018 23:33:39 -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=ZACXIEqz; 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 S1030351AbeF2A3y (ORCPT + 99 others); Thu, 28 Jun 2018 20:29:54 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:41229 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935951AbeF2A2z (ORCPT ); Thu, 28 Jun 2018 20:28:55 -0400 Received: by mail-pg0-f68.google.com with SMTP id l65-v6so3178497pgl.8 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=lM7Xuiq23lhBqJ5443dVH7pyrjb7fp0MWjopUDnQywi1QrGzqwqURS3X5F9FrqJcYU T0TVQeiz9GcY/IznYB6ycu0chV147iVnosuwa8erOm/OppjUVc1gEwCXpfGq/a1Jf6VX tAkfF9AyDl+WJ32EOIEqBM7UE7dy9wpXhXdeDXxDe2HkeDhpSlGdUGVnSxQ6Wj0zOTEE K1YJauncC2p00D6cSV+Qd2HtZUpe+E716/4DQBjHQcbFWNwGx6lpAijp94WzRCRJIOvS DTVaEmAS93Niu2fWx64/gbyA/EmaTZDFErHZfb2ZoXceM78rSkxlUMlIjzam0r4HrXWz Sulw== X-Gm-Message-State: APt69E39MFHDSJysICI/cdlliVHDGtJJwUsxz5YRc/jU10afytLE8EXW o/BETrJnyCEH6/Qsb+0VYltdxQ== 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-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 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 -- 2.17.1