Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1409385imm; Wed, 23 May 2018 15:52:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZonKsyUJhPMyRBYPxsV1RYBwxzR/Xd9LMRjBkdiAs4zf8fcOlnllL7QGG+SSvymq394eFKt X-Received: by 2002:a63:79ca:: with SMTP id u193-v6mr3830091pgc.112.1527115937701; Wed, 23 May 2018 15:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527115937; cv=none; d=google.com; s=arc-20160816; b=aX72jGB/L0cgy/0Fg/n0/kjoB9bB3AvqT9cdGD3lxckSm4gmyNtbmKlOjHIQu4S/Rr 8LikVIngKk9PEKP+sS3/XDKYw446R4bZkFMAztE+hgluCFa3GmkUHnV4PEMwtmV39JEF rrUvs0A6Zz6lFGVLvHb+SvqCH/tza2FdUEUTLgVgv9wNK/2vwAGJD24k4vmHcNXZsRRS zHdEU0bx00imJji6PYEBSAharWczvA/wOsjoSWDI1nvBSBFccWQo5EItZxh5ZaxUU3Xq sp+D2b3ahTVnAL9LbOMhLlptpRQ+JQXyg8qZ5KBHofuwlG+g5/VIKOw0LHtdEIMtZ6Tn 0a6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=PT7SCbF3zRxXpBRgdZYdBfR66sSHygUu70qxdpDFzy8=; b=D/BKa72Cvem71/ByZ/cV1Kb+bdn3MWoZJJrbBIxS8pD3mlsJ3tkcTOrYIKLu9Bj9cK th+8qfSrBVz5fLcFIbysZs+ZUzudguAWZ/4X81g1EUe/yjO++Sn1AvP/Af0N988vr4v/ zt/bvyoDh1gVgCwod6Cp9mSbM8YitLYJDJhKvvQ2j0wuWImMl5abI6vZz8a3T5mAIExe 0qY2+h8ZYUa6Id5DapRm2qeRV7MEZ50OEyzqLpfUX2rxLbHeoP6EDmssxF4IvP9lEkJ+ 50yZpmPZySCLJlRZq7X0DZT2fxpbvkASZvk2A/Vt1tUe3YDj/tEaj42aVfXbsKWb+keS m9/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=toyw6JIw; dkim=fail header.i=@chromium.org header.s=google header.b=PaIe68Ih; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5-v6si15720722pgq.343.2018.05.23.15.52.02; Wed, 23 May 2018 15:52:17 -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; dkim=fail header.i=@google.com header.s=20161025 header.b=toyw6JIw; dkim=fail header.i=@chromium.org header.s=google header.b=PaIe68Ih; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934948AbeEWWvx (ORCPT + 99 others); Wed, 23 May 2018 18:51:53 -0400 Received: from mail-ua0-f196.google.com ([209.85.217.196]:38498 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934516AbeEWWvu (ORCPT ); Wed, 23 May 2018 18:51:50 -0400 Received: by mail-ua0-f196.google.com with SMTP id y8-v6so15894013ual.5 for ; Wed, 23 May 2018 15:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=PT7SCbF3zRxXpBRgdZYdBfR66sSHygUu70qxdpDFzy8=; b=toyw6JIwL4rYRwUp2juXA2asMTz55Xapoq+T+TOqlpGOpEACXrryGumy9MVRVgztBj x02K4TxArSW0FcHp4KALzNis7RdYIrzfCw5tS5Ch47To+CUtbg85hY1fvDu+m/5oPXmm uGmjit5SB7Uf4KtW11L76EqZYg1GoWAKgojDK0aktgJJX4NKEke2lM1UYAuhenAZp40p W/cwe2NcUD6dar3XGxveNGrzdNwKMsMJgMnhKm27wyIjRLoJl91dyityVnwQBFHS04bN UHGW99D8yBn019BGbhY48i6smBkE/KhRwj2OccaJ46HV77EBE27UJRdZeClaOc6D/CgG QcVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=PT7SCbF3zRxXpBRgdZYdBfR66sSHygUu70qxdpDFzy8=; b=PaIe68IhPLFBu10ORB81Q7uewMbqmgEa5rXOiIW396zCalCaAS4Sajp6CEBDBK14qA 5LOu5BSp5FFDNRmj0G/71YyPFwJxSO8MyhSIShYS6Z6Bw2G9NF2sayWAS20SB7ST6msF 2smDP2qng8JoPbwrr7V0lv8uZ+6JAMOff1i4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=PT7SCbF3zRxXpBRgdZYdBfR66sSHygUu70qxdpDFzy8=; b=Io14sPDzkYXbkcRTOyaLL3i3D3iZnLkWd66XHlDD9zhEFPdCd+DbG8eYfvjoI2JUSy 7o1MzdWheid5aPSSBPTq4u0JFJ4Va8sNghKMg7HdNU6NpSE9A8cCI41sGSUjP3S5AgVe 0nNRSilxtiFZMA590ChKaSXZUw0SlYDjTc++KodBRfn8smaFrq2HqJJI1jD3IJiBwO7t lWo/6WPyVE3tiII2PCIGQgZw7TB7ruFgbv/R5ulAxt3tOTNx5x1ubioRaieh+XjZ9SwT tdElay+cqDOW3jFqmBScos1tUePUwXXOsM2qV5bxLXBI+0ZFECu9tflX4gBo9bSPtiEJ P3Vw== X-Gm-Message-State: ALKqPwebkZccxsUPoMogA9jyKUUVuXr+ruTT0q4Hnv4D/JgR/Cl06q7K EU82NPont8mC4A5BFaxp91jie2irk8OqIKddvHZJBQ== X-Received: by 2002:a9f:31c7:: with SMTP id w7-v6mr3297876uad.176.1527115909079; Wed, 23 May 2018 15:51:49 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1f:bd1:0:0:0:0:0 with HTTP; Wed, 23 May 2018 15:51:48 -0700 (PDT) In-Reply-To: <20180328175957.23904-1-labbott@redhat.com> References: <20180328175957.23904-1-labbott@redhat.com> From: Kees Cook Date: Wed, 23 May 2018 15:51:48 -0700 X-Google-Sender-Auth: _bVW6TCRAe00dRlMQl3aOR6h_rQ Message-ID: Subject: Re: [PATCH v3] gpio: Remove VLA from stmpe driver To: Linus Walleij Cc: Laura Abbott , Patrice Chotard , linux-gpio@vger.kernel.org, LKML , Kernel Hardening Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 28, 2018 at 10:59 AM, Laura Abbott wrote: > The new challenge is to remove VLAs from the kernel > (see https://lkml.org/lkml/2018/3/7/621) > > The number of GPIOs on the supported chips is fairly small > so stack allocate to a known upper bound and spit out a warning > if any new chips have more gpios. > > Signed-off-by: Laura Abbott Reviewed-by: Kees Cook Linus, I think this patch is still needed and got missed? Can you take it as well? Thanks! -Kees > --- > v3: Split this off from the rest of the series since some of the > patches had been picked up. Switched to just hardcoding an upper > bound for the stack array since it's only a few extra bytes > of stack space. > --- > drivers/gpio/gpio-stmpe.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c > index f8d7d1cd8488..8d6a5a7e612d 100644 > --- a/drivers/gpio/gpio-stmpe.c > +++ b/drivers/gpio/gpio-stmpe.c > @@ -363,13 +363,15 @@ static struct irq_chip stmpe_gpio_irq_chip = { > .irq_set_type = stmpe_gpio_irq_set_type, > }; > > +#define MAX_GPIOS 24 > + > static irqreturn_t stmpe_gpio_irq(int irq, void *dev) > { > struct stmpe_gpio *stmpe_gpio = 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[DIV_ROUND_UP(MAX_GPIOS, 8)]; > int ret; > int i; > > @@ -434,6 +436,11 @@ static int stmpe_gpio_probe(struct platform_device *pdev) > struct stmpe_gpio *stmpe_gpio; > int ret, irq; > > + if (stmpe->num_gpios > MAX_GPIOS) { > + dev_err(&pdev->dev, "Need to increase maximum GPIO number\n"); > + return -EINVAL; > + } > + > stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL); > if (!stmpe_gpio) > return -ENOMEM; > -- > 2.14.3 > -- Kees Cook Pixel Security