From patchwork Wed Apr 11 01:02:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10334683 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 B8095602D8 for ; Wed, 11 Apr 2018 01:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5C1C26253 for ; Wed, 11 Apr 2018 01:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA885285DB; Wed, 11 Apr 2018 01:02:47 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 C44E126253 for ; Wed, 11 Apr 2018 01:02:45 +0000 (UTC) Received: (qmail 1599 invoked by uid 550); 11 Apr 2018 01:02:43 -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 1580 invoked from network); 11 Apr 2018 01:02:43 -0000 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; bh=O8WfciiDYl7Lhr+NJARHFTMcRAkCHWWB76RpECIFM0U=; b=iWvp2pqR07XXzJJB8z5zlS/lfWblLc6BhIXHocVrG0Ifc9wPpWoem6pd8U3PqtMSHH CDA89Biukji8qCyJTL3We2ue0TBUjaRf5xCn9QcFzRddj9SMSSg8JGN1U9JFcaG8kR5N ypsC9QspbORwPgsh6+lqar8rgove2YL1AgZs8aXz3HpNuWnRW8yBLkI9mwHZAllsONlw 70tLxaZqs3nLPMma/a9ZtJ3tyVe8zBFu2M8ys7c8hxBFBBTlW6Qro7paTMjGTECZM5H1 T7sj5fEIKNbDeZMevpqX8JQRBwnxHDtepMhpsa4pcjxhqxt3pyCRnkupqCw8T2CdQJGB sa/g== X-Gm-Message-State: ALQs6tCHKfK1Z0Obmu4IRPnkYRCvxBw/Wjer55MRHTSVMWqXcik/fxNf iwE081kIsvsd8oDwjSTYXVNAbg== X-Google-Smtp-Source: AIpwx488CJqcYz+zciXGLj1gfZVu1/5k6/Ad1r+2+wh2qf6SReq2a5EL+WBGbdIcVyrBYjNwp3pZsQ== X-Received: by 2002:a17:902:8b84:: with SMTP id ay4-v6mr2665172plb.57.1523408551380; Tue, 10 Apr 2018 18:02:31 -0700 (PDT) From: Laura Abbott To: Vinod Koul , Dan Williams Cc: Laura Abbott , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kees Cook , Sinan Kaya Subject: [PATCHv2] dmaengine: dmatest: Remove use of VLAs Date: Tue, 10 Apr 2018 18:02:16 -0700 Message-Id: <20180411010216.17702-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 X-Virus-Scanned: ClamAV using ClamSMTP There's an ongoing effort to remove VLAs from the kernel (https://lkml.org/lkml/2018/3/7/621) to eventually turn on -Wvla. The test already pre-allocates some buffers with kmalloc so turn the two VLAs in to pre-allocated kmalloc buffers. Signed-off-by: Laura Abbott Reviewed-by: Sinan Kaya --- v2: Switch to using kmalloc buffers instead of putting a large array on the stack. --- drivers/dma/dmatest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 80cc2be6483c..9730956dfbe3 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -463,6 +463,8 @@ static int dmatest_func(void *data) unsigned long long total_len = 0; u8 align = 0; bool is_memset = false; + dma_addr_t *srcs; + dma_addr_t *dma_pq; set_freezable(); @@ -546,6 +548,14 @@ static int dmatest_func(void *data) set_user_nice(current, 10); + srcs = kcalloc(src_cnt, sizeof(dma_addr_t), GFP_KERNEL); + if (!srcs) + goto err_dstbuf; + + dma_pq = kcalloc(dst_cnt, sizeof(dma_addr_t), GFP_KERNEL); + if (!dma_pq) + goto err_srcs_array; + /* * src and dst buffers are freed by ourselves below */ @@ -556,7 +566,6 @@ static int dmatest_func(void *data) && !(params->iterations && total_tests >= params->iterations)) { struct dma_async_tx_descriptor *tx = NULL; struct dmaengine_unmap_data *um; - dma_addr_t srcs[src_cnt]; dma_addr_t *dsts; unsigned int src_off, dst_off, len; @@ -669,8 +678,6 @@ static int dmatest_func(void *data) srcs, src_cnt, len, flags); else if (thread->type == DMA_PQ) { - dma_addr_t dma_pq[dst_cnt]; - for (i = 0; i < dst_cnt; i++) dma_pq[i] = dsts[i] + dst_off; tx = dev->device_prep_dma_pq(chan, dma_pq, srcs, @@ -772,6 +779,9 @@ static int dmatest_func(void *data) runtime = ktime_to_us(ktime); ret = 0; + kfree(dma_pq); +err_srcs_array: + kfree(srcs); err_dstbuf: for (i = 0; thread->udsts[i]; i++) kfree(thread->udsts[i]);