From patchwork Mon Mar 12 01:37:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10274977 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 DF53660211 for ; Mon, 12 Mar 2018 01:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D252D28694 for ; Mon, 12 Mar 2018 01:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6C78286A1; Mon, 12 Mar 2018 01:38:28 +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 0460428694 for ; Mon, 12 Mar 2018 01:38:27 +0000 (UTC) Received: (qmail 17822 invoked by uid 550); 12 Mar 2018 01:38:25 -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 17779 invoked from network); 12 Mar 2018 01:38:24 -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=61aQHP3KmWAPxeQr2SKB3KrIxlinVRPa4WaE8+Lph v0=; b=MMkVSlURzP+SfwuqBN2WDWFUXwZc8cgOG0REr6NQEYQ8B2yOUykMbsqUy wnGHC9C97UH3X0GMdCgr+Xp9HBf6KisXZVnkNCjA/65uBlMSjT2zTGh8HHrR6Omo OmWOcK1pcQ5X5KbG6kizxzwcEszjzEfYkrQOWGzPIT0mHk+1ozfwzIx59RTCujeb S4tWjK1mOZ/IRWs35djHtFtFHyNr2qYdlL6wKDPLWx77ugvfezivS6Sw9rWJiRlP rxtoxA39C+xR8Y1PlLzXomWqyJhcXVrapfU7ZsminKUo+uVPRedngdBQBZeapkXu RnziKf9HXPamd5JcPMAbIZXoyYUgA== 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=61aQHP3KmWAPxeQr2 SKB3KrIxlinVRPa4WaE8+Lphv0=; b=Z5q3HKbDkG6RRZ2bbywPas5+qwMeoYdoI S0m7+6+qVcIcA5NrCNa5oJEdad++KCT/2zcA5+u73m+QGx6W8fesOwSo0313a7Zb KhvIcosFjX76g27n36WiZ/ItnInoVhZRy6HZy0MFL7TIGMKEMXq+VfyijCZZ+ydq 7xl/6n/d1IYCrKQbmMV4UubfTVbbwm0mq0P6ZEeSAPbQaotbnmcMRRDWY5EmMifv 8/oeghxUVYZhaJZ3zz4YuBLVV+EA8X+ZJt9AZYvYmlk6iyiXcYXI6v6oxxwI+OYA oDoyaarnJmuPoB3KT5KIx0c8uydrkqylO5AEidKK7kLYXia0i8eww== X-ME-Sender: From: "Tobin C. Harding" To: Greg Kroah-Hartman , Eric Anholt , Stefan Wahren Cc: "Tobin C. Harding" , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, driverdev-devel@linuxdriverproject.org, Tycho Andersen , Kees Cook Subject: [PATCH v2] staging: vchiq_arm: Clear VLA warning Date: Mon, 12 Mar 2018 12:37:53 +1100 Message-Id: <1520818673-14084-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]. The array here is fixed (declared with a const variable) but it appears like a VLA to the compiler. Also, currently we are putting 768 bytes on the stack. This function is only called on the error path so performance is not critical, let's just allocate the memory instead of using the stack. This saves stack space and removes the VLA build warning. kmalloc a buffer for dumping state instead of using the stack. [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding --- v1 of this patch already merged into staging-testing branch of Greg's staging tree. This patch depends on v1 being removed, can re-do this one on top of tip of staging-testing if required. v2: - Use kmalloc() instead of the stack Patch is untested. drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index f5cefda49b22..408ea73f8da7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3455,11 +3455,15 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state) int fourcc; int clientid; int use_count; - } service_data[local_max_services]; + } *service_data; if (!arm_state) return; + service_data = kmalloc_array(local_max_services, sizeof(*service_data), GFP_KERNEL); + if (!service_data) + return; + read_lock_bh(&arm_state->susp_res_lock); vc_suspend_state = arm_state->vc_suspend_state; vc_resume_state = arm_state->vc_resume_state;