From patchwork Fri Jun 29 18:51:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10497267 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 C16C9601C7 for ; Fri, 29 Jun 2018 18:52:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97D9628F4D for ; Fri, 29 Jun 2018 18:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C4EE28E96; Fri, 29 Jun 2018 18:51:55 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D2FA28E63 for ; Fri, 29 Jun 2018 18:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ZHk3PKM2A1EPNe019lNb0G+fIZL3jxCN8UUZOtK+smE=; b=UXR7imRBQ0T/iv 1IboOL10M0JlJkrohu3d+TgyYKXUmwmFEgaFIhD5VIMoqc0uwY8B4kxhlIjhIorxDHcuCId0hMa9P 25m1qA3hFJq5eQO2VJ8pD9YGET0nDXjcvUU5m5kejXYyC2d4u3U5sNBRT22gwTqnc7bDcuG+e3XxL rblT4r9b+pNMmgS2APkcokJaMo9OOUiFyLHiN/GRBe4/RHQfdFKzeWhN7iLahc1FTdlUIabMD7cD4 g/OahRHBolgUqZPPvAwfcxKd+CG3f6u0Pygm8w9ntl4r7WJx4gnQ9v8m9Mi7KQfPmflszoriN8lZy TaZzJ3iL9fmTDSXOsEmw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYyUp-0006o2-8R; Fri, 29 Jun 2018 18:51:51 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYyUK-0006Tv-05 for linux-arm-kernel@lists.infradead.org; Fri, 29 Jun 2018 18:51:30 +0000 Received: by mail-pg0-x242.google.com with SMTP id a14-v6so4360570pgw.10 for ; Fri, 29 Jun 2018 11:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=V/ZfJVZhF6dv8FNKwlwqRUc+ojoCtaZDQBWtteUwh3s=; b=XdVvv8K95TJhZiMbixlP8cLH7fGSXHX+6d/+lU9UxcdmEtgXf+q0SRHZI1ohnWtkJw 5RgY5tNqqZ0svKDnNddnhrR5DQQnwKvxjGQD+gQ2tBh0Z0CSaNXBaKe28kcFoIaQNd12 XS/TdJE/e9XcS9gHYg2601EJVPWnpuDZM+2y0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=V/ZfJVZhF6dv8FNKwlwqRUc+ojoCtaZDQBWtteUwh3s=; b=IRmwZ4pvvUjDmafATqKzSFX/NnpON09GTY0Jg4hsBxAwTcezVc9eM3+WWG1DgqXWLu 60uQY1ikXyLENhxkLBgXNcx7IknKzyBYuNzm2h60wIwiGr8GEw0AzES7+U3+CcDX9BC6 iTrEnqHTmQSfY1kKKqBM5SdK0z8vUun565XwKcpuqWE/HeSbJ8yQ0F9gPXfMEOhyeJEv iZhUVFQX2JAhxjZG5SB29g+s5xuP0XIxuqxPQ2LP9tV5aKc9sCUJLzDTliTScErAUOZv NcLn8v4WFk0X3LStzxoRmIzd+gYE/5Qay0yjLxXHyDe5nCRReCY7eWbxq2AwQuVxLUQx R0Kg== X-Gm-Message-State: APt69E3lvRGMmcw0qOtXN6vzVOkHHR3K34jD6zeca+CY7v+eS1kVo9wE E6JoFiLr/2YM2GOxarjR/J0fDVCh5So= X-Google-Smtp-Source: AAOMgpfYPT72+A1Zq0N0ymJVWBuKAHMxdoXtxl4ttz+q5OWnxKctOBNDB9NOyQ2mLJ5n1A5gEn4iUQ== X-Received: by 2002:a62:f50b:: with SMTP id n11-v6mr5732417pfh.120.1530298269397; Fri, 29 Jun 2018 11:51:09 -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 r79-v6sm20782690pfk.153.2018.06.29.11.51.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 11:51:08 -0700 (PDT) Date: Fri, 29 Jun 2018 11:51:07 -0700 From: Kees Cook To: Linus Walleij Subject: [PATCH] dma: ste_dma40: Remove VLA usage Message-ID: <20180629185107.GA37488@beast> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180629_115120_697090_571AF298 X-CRM114-Status: GOOD ( 14.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmaengine@vger.kernel.org, Dan Williams , Vinod Koul , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In the quest to remove all stack VLA usage from the kernel[1], this switches to using a pre-allocated scratch register space, set up with all other other allocations. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Cc: Linus Walleij Cc: Dan Williams Cc: Vinod Koul Cc: linux-arm-kernel@lists.infradead.org Cc: dmaengine@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Arnd Bergmann Reviewed-by: Linus Walleij --- drivers/dma/ste_dma40.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 1bc149af990e..f4edfc56f34e 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -555,6 +555,7 @@ struct d40_gen_dmac { * @reg_val_backup_v4: Backup of registers that only exits on dma40 v3 and * later * @reg_val_backup_chan: Backup data for standard channel parameter registers. + * @regs_interrupt: Scratch space for registers during interrupt. * @gcc_pwr_off_mask: Mask to maintain the channels that can be turned off. * @gen_dmac: the struct for generic registers values to represent u8500/8540 * DMA controller @@ -592,6 +593,7 @@ struct d40_base { u32 reg_val_backup[BACKUP_REGS_SZ]; u32 reg_val_backup_v4[BACKUP_REGS_SZ_MAX]; u32 *reg_val_backup_chan; + u32 *regs_interrupt; u16 gcc_pwr_off_mask; struct d40_gen_dmac gen_dmac; }; @@ -1637,7 +1639,7 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data) struct d40_chan *d40c; unsigned long flags; struct d40_base *base = data; - u32 regs[base->gen_dmac.il_size]; + u32 *regs = base->regs_interrupt; struct d40_interrupt_lookup *il = base->gen_dmac.il; u32 il_size = base->gen_dmac.il_size; @@ -3258,13 +3260,22 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) if (!base->lcla_pool.alloc_map) goto free_backup_chan; + base->regs_interrupt = kmalloc_array(base->gen_dmac.il_size, + sizeof(*base->regs_interrupt), + GFP_KERNEL); + if (!base->regs_interrupt) + goto free_map; + base->desc_slab = kmem_cache_create(D40_NAME, sizeof(struct d40_desc), 0, SLAB_HWCACHE_ALIGN, NULL); if (base->desc_slab == NULL) - goto free_map; + goto free_regs; + return base; + free_regs: + kfree(base->regs_interrupt); free_map: kfree(base->lcla_pool.alloc_map); free_backup_chan: