Received: by 10.213.65.68 with SMTP id h4csp666574imn; Tue, 13 Mar 2018 17:19:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELu9uTfjLrQJrLJh9n28f73kO2z2FnJrFF1HsSoJ6WwClrJk9CmxrEm/xjJGVGu4KJK9uQcO X-Received: by 10.99.147.11 with SMTP id b11mr1943218pge.379.1520986784914; Tue, 13 Mar 2018 17:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520986784; cv=none; d=google.com; s=arc-20160816; b=kgLAHci6xYF3zBy2EpowJQHBiHrGJBF1OpulilGEqjKQFDOMMkgPIadTqMzY5qNGaw fhXuCgVYa8Smj94dN4blWzeD+fNeDKfxpIqJu22o7YEJT1orWC9DAIWtWa7GIg2LbqGD UHh6yWrB0Ru5QtvkGMlZpz0fdTeWvgANFmDdv8q6OhDlytEVviXhtsjLAn3owxHTPHAY PJ2k9cuS/eLa/ulCffxKmxjiyM0wD/0RlRHdvfQhwvjiorCqaycl/ut9dva7rf9d+IBk 5h7QW1EWCyGEgT3rJSC5ujrb/X+TjzovGgyAzBOaVIFiNgT3C7+AEBOo9sXAI9cT1xU8 iCSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=mdY2p0D+b0virh/3/wlRN9oZbQIou1TZv+VAOAEbH6w=; b=bFKmipZxln132dhN91eP8mZL5qXEH3qMvYUEABmNmPdps3CTP5UpMfw20XbRtuwXaq 7ZHMHoO7VnhSeVfdnG56fM++Gh4G1nxGCZZ7UYmdrJbTnpLIKAYd2uIVOGy1bYh8jEE8 fpV1RJPHk0PbPu9V76jz1UsCD8yJdu2l4fXlsco4mnj6CNOi+cK24PKiyucprpwMEolg ybEEytlRAVZiv8OZV6/7Nm5t2cCQLyjVYpc97kV8IqxNetZ4X/eah3QvIA7Gb85Nl/db JmPEjSaU0JFm8JLs45RISL25QV5PpFZ0fvjjEki8tE7yuY11LnpCLXrFqHkbSlBozfmd E0sA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b187si891092pgc.205.2018.03.13.17.19.28; Tue, 13 Mar 2018 17:19:44 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932858AbeCNAS3 (ORCPT + 99 others); Tue, 13 Mar 2018 20:18:29 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:43380 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932634AbeCNAS1 (ORCPT ); Tue, 13 Mar 2018 20:18:27 -0400 Received: by mail-ot0-f195.google.com with SMTP id m22-v6so1518269otf.10 for ; Tue, 13 Mar 2018 17:18:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mdY2p0D+b0virh/3/wlRN9oZbQIou1TZv+VAOAEbH6w=; b=ksW850+lzBRhs5IAeCO3uRNWQOUL+kllC/ay+BZJ2vSit0N46RQHIj1lySIc8P1Qmu AcN163yWhKEl3KTXf+x86WM4IPIV657JggIfUgXMk+VUM5LmhvnSGsJD4uqQKFWTlhnX ENE9k7ZgdiYLH6FUMylO+qNcg1ZWx/emcrM6tvQ9QWD26B4zaH1u7QaeSxeNmjenku6h GmLZBv7KUwc8gct9wgMhHqGI6GYCwBxxBOhPQU0qfXfrWdJkBTHXNp0h0WiujZ5UdVK1 j4xudRO6d8fs4lwmpkv77hTXxPrw3h8wuhUS0O+WCKOUnd04QBogJlBDItlgTtH232wD apwg== X-Gm-Message-State: AElRT7FWRy34O4ZvRWS4tXynEBntBvQ6HYfdXUx5bAJo7D88wbwWQ+hr EYvkpQJbLDEZMzk4UFOwM8kDUA== X-Received: by 10.157.63.228 with SMTP id i33mr1701760ote.51.1520986706654; Tue, 13 Mar 2018 17:18:26 -0700 (PDT) Received: from ?IPv6:2601:602:9802:a8dc::b761? ([2601:602:9802:a8dc::b761]) by smtp.gmail.com with ESMTPSA id b124sm813344oif.28.2018.03.13.17.18.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 17:18:24 -0700 (PDT) Subject: Re: [PATCH 4/4] gpio: Remove VLA from stmpe driver To: Phil Reid , Linus Walleij , Kees Cook , Patrice Chotard Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com References: <20180310001021.6437-1-labbott@redhat.com> <20180310001021.6437-5-labbott@redhat.com> <9175611d-049d-ec28-0716-e45fccfd579f@electromag.com.au> From: Laura Abbott Message-ID: <4e64bbae-e91b-f0c5-ff79-3dde8fbe2119@redhat.com> Date: Tue, 13 Mar 2018 17:18:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <9175611d-049d-ec28-0716-e45fccfd579f@electromag.com.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/13/2018 02:13 AM, Phil Reid wrote: > On 10/03/2018 08:10, Laura Abbott wrote: >> The new challenge is to remove VLAs from the kernel >> (see https://lkml.org/lkml/2018/3/7/621) >> >> This patch replaces a VLA with an appropriate call to kmalloc_array. >> >> Signed-off-by: Laura Abbott >> --- >>   drivers/gpio/gpio-stmpe.c | 7 ++++++- >>   1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c >> index f8d7d1cd8488..b7854850bcdb 100644 >> --- a/drivers/gpio/gpio-stmpe.c >> +++ b/drivers/gpio/gpio-stmpe.c >> @@ -369,10 +369,14 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev) >>       struct stmpe *stmpe = stmpe_gpio->stmpe; >>       u8 statmsbreg; >>       int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); >> -    u8 status[num_banks]; >> +    u8 *status; >>       int ret; >>       int i; >> +    status = kmalloc_array(num_banks, sizeof(*status), GFP_ATOMIC); >> +    if (!status) >> +        return IRQ_NONE; >> + >>       /* >>        * the stmpe_block_read() call below, imposes to set statmsbreg >>        * with the register located at the lowest address. As STMPE1600 >> @@ -424,6 +428,7 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev) >>           } >>       } >> +    kfree(status); >>       return IRQ_HANDLED; >>   } >> > > Doing this in an irq handler seems wrong. > Perhaps better if a buffer is pre-allocated in stmpe_gpio > > Sure, I can pre-allocate the buffer in the probe. Thanks, Laura