From patchwork Fri Mar 9 06:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10269753 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 229AE602BD for ; Fri, 9 Mar 2018 06:11:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0915929CB9 for ; Fri, 9 Mar 2018 06:11:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1D3C29CC0; Fri, 9 Mar 2018 06:11:42 +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=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 2B3C029CB9 for ; Fri, 9 Mar 2018 06:11:41 +0000 (UTC) Received: (qmail 17773 invoked by uid 550); 9 Mar 2018 06:11:40 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 17715 invoked from network); 9 Mar 2018 06:11:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=HKPOGpnBfVn8jLhN2nR5abhck4NDqvdfjyrozhKWZ hk=; b=ObR6XFXT0KaaBlm60iJHneLisPd22cnDeQL2/kppr9gYBMU/V/RxXpXS5 PUZF+bw8FHwfqVGFJWs9V1YeF6Y7nfmb/X6/FPSnDQE1opjLu3XMOqQZGjida8UM p3RHfj16mGVN25vxmvZ8rTXmJ1devF1t3uWIPRx65BwznxczQlopynyKR6Jt3KUH RFH7NFe+PkE9/nCugl10d0WVs1qbYl6lBgAHNzXgMa6x7wMF+CugpC7MhJzmxPzv KB4WoqL4+DbQdrowJyHZGMbmrxkGlIttjLNo3VakE5MhK0F17S2hLXTj/3NBWAff xHPtCI6hTRNP6nqn6L0wmp2TsPdGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=HKPOGpnBfVn8jLhN2 nR5abhck4NDqvdfjyrozhKWZhk=; b=VzrNIVnQQjNbCbdMGcERk8R66vesteZ7y B0d2DUaMrEi35setMDPi/KI6Fx+Kh/3btPS046VIO7x8Oo8KzNcqns6JKN1CpHbN 8yuRk6m5LtKkFjaaT8y/YMnp0OzpEmXcr46IzMdaS65sRV12D6il602zC/ZJUFK6 iUw32nEJa5aS5BGcOSTQmuYmbs6nO5hDlbsA3GNteqnBaPV8YrM9GrURRyyUf+cZ hi55yE5pAOr3PGE8OTWxYsijeP0e/pvIqACsBRQLpm1eECXo1ET/f/fat+vImLoo 03Hf2pLcUIJFCRpjkD25yU5s2972Y43cHE4nTlY3N4P6z77u/mxkg== X-ME-Sender: From: "Tobin C. Harding" To: Greg Kroah-Hartman Cc: "Tobin C. Harding" , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Tycho Andersen , Kees Cook , Felipe Balbi , Alan Stern Subject: [PATCH v2] usb: Remove stack VLA usage Date: Fri, 9 Mar 2018 17:11:14 +1100 Message-Id: <1520575874-15281-1-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP The kernel would like to have all stack VLA usage removed[1]. We already have a pre-processor constant defined MAX_SGLEN. We can use this instead of the variable param-sglen. [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding --- drivers/usb/misc/usbtest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 90028ef541e3..9e1142b8b91b 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -2028,11 +2028,14 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param, unsigned i; unsigned long packets = 0; int status = 0; - struct urb *urbs[param->sglen]; + struct urb *urbs[MAX_SGLEN]; if (!param->sglen || param->iterations > UINT_MAX / param->sglen) return -EINVAL; + if (param->sglen > MAX_SGLEN) + return -EINVAL; + memset(&context, 0, sizeof(context)); context.count = param->iterations * param->sglen; context.dev = dev;