Received: by 10.223.185.116 with SMTP id b49csp6700094wrg; Thu, 8 Mar 2018 11:42:56 -0800 (PST) X-Google-Smtp-Source: AG47ELs4eqmbr1u6Ipdk13DmULvQFezaqA3PISZMe9PL4GVyiXekG8XohhX188459QZpjrPCzDtW X-Received: by 2002:a17:902:8691:: with SMTP id g17-v6mr13078982plo.7.1520538176377; Thu, 08 Mar 2018 11:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520538176; cv=none; d=google.com; s=arc-20160816; b=YssmMAJGa3x21dyNqUqOrsnatwtSEcVwXTlUWnQ7v4QxmcwtDFTyBKp5Tyc5YA4eFt iE4wzw8fvBLZNKHSARutPOTDnvry60nNVDitaDoWqwrIGuTEsi0A3v0PcdyNgr4pPw8T QKKZCCUQUxxG6URSl4K+9IrQZwhLWrYlRBOAYcAEfmhkuuFTp6LhN4mYWJjZjFcURaIp 74/lBKKUOqBwdLsaade5a+JbD4IGSp3ocejVgAhAMDv5SjhPaVHD9MuNjn64XKtvfWNf ImIAfNboYNKGjNh5JTKe8wF+AW2J233ESWGs0Am1cKT7IToWU3UV+dWLNqjOr9BQSxT+ GU2g== 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=p2sER9UOTzPrAJBIgLfs15ecQFFFowg9q27ipvt8WgA=; b=xQFkLniKGbxXHMwY/YaHL9CWgnzs5djEmYsh5AbCuCBVx0LdZaesikw9Pp4exR1Sn1 ht3werSTe7M++xns1ah1KTgYtm4lHvCfb27kBSPpBlx/20MAf0UIlJbNbV5wE6oRpCB4 J9fzC6bbQ7H3Rd7tAwRzYEK0opMZT/lwQY3zAEhLow1qrFE8JnX2Na2lIOajcVTAoab9 bRmcWn3qkC8vDB5xLiWwirIG+GeXQox0/x4cwC9vcIiwXyfOj3KlGVuTNh4zYiYW7Ws2 1kPTeRWiskA+EEV3nLO49qrmuAgbnXSMxxlTAvMFgmEGj0OTlP7rsZqEhoyf0fTKim/D uE5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=OTJtMwdb; dkim=fail header.i=@chromium.org header.s=google header.b=T5gL42ja; 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 1-v6si15226163plk.52.2018.03.08.11.42.06; Thu, 08 Mar 2018 11:42:56 -0800 (PST) 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=OTJtMwdb; dkim=fail header.i=@chromium.org header.s=google header.b=T5gL42ja; 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 S1754696AbeCHTjT (ORCPT + 99 others); Thu, 8 Mar 2018 14:39:19 -0500 Received: from mail-ua0-f195.google.com ([209.85.217.195]:45853 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752320AbeCHTjR (ORCPT ); Thu, 8 Mar 2018 14:39:17 -0500 Received: by mail-ua0-f195.google.com with SMTP id n24so625304ual.12 for ; Thu, 08 Mar 2018 11:39:17 -0800 (PST) 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=p2sER9UOTzPrAJBIgLfs15ecQFFFowg9q27ipvt8WgA=; b=OTJtMwdb4wXp/SjcWJrlvc7FfDv958WAjZKyszxPqh+3tKXjPYAA6Ax5nWDW8slZmJ WHF28MuCw3qft1C0zJ6jmO82Jrkl5vtIpk88Qn5+GHmxWIihdfvXonpfa1C27DoIbndH gC6twMsCOuQJO8vI2WKPIDNzlj0HyqA60leV2MjzYI5HFPJ9iAkVjaenjmiuI5t57x8O ebyGo2qHraMI5Jd0aFuNH2PtyV1aMQFa6MANLcAp+mypy7hUki70mnvZNqvfHjG2gYMW xRC1mhJlNAFiZ1c0+84uP91pF3RWdNbLwDWXqPqY4DHfS83qySydQCelnG3ThA3K3ELF QpmA== 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=p2sER9UOTzPrAJBIgLfs15ecQFFFowg9q27ipvt8WgA=; b=T5gL42jaeyVJ98m7L+kAdRRmL9nlaJYIakghqh0TTdlD0efOPsO1wAfW3dvs2juPzu 3TABdRtLEPRHr/j1glL2Wk9AAoDQ+YwjCbSxd8BEvEMQi/Qfpn1CYxDu7gHa6WiPz20B d9bttaMJmyeeumt3MBKEzbNF+4QdFNvqM4zrk= 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=p2sER9UOTzPrAJBIgLfs15ecQFFFowg9q27ipvt8WgA=; b=HiP0SVq51xUlKo6n45Xhcrr3LukW8tCQ/LnlprHG9ntcgTc47z3w4fJ2V7c8l52lwt aVQRFI6ztIx/YaNJ0MBMMYHxNWL9s3sCKOD+tmIfxz4PYLEKsvoyBnh/WfEd3VQG4RH1 FcKSPyV4j4gGridfm5BchA8fnXDC96gbbKZdqH4DPskWlQnotGJD1EOojheirAsb3A4i cKSOZ7yQrMVoYKZFicUxDYIRNJns4FYb0a9bmDozBiRAwsKEL7iucnDT3eHdwx0JnY2e V5ROPncSzR4OZ6Yqy/sDQq/IjTGnZdW7q3f9icZRSL30RZKl/hCBUEaTzcI8ib9pUDlW c9lg== X-Gm-Message-State: APf1xPDWfusIXGJxePc5KzJTYUqN8/XVB8zTbczm3iOLWiMxWs40UubR 4Pj6Bdm2LnlpQB5eGq05V9H/SprTgPUall0xp9QcpQ== X-Received: by 10.176.22.50 with SMTP id k47mr20380114uae.176.1520537956564; Thu, 08 Mar 2018 11:39:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.242.140 with HTTP; Thu, 8 Mar 2018 11:39:15 -0800 (PST) In-Reply-To: <1520534733-1743-1-git-send-email-himanshujha199640@gmail.com> References: <1520534733-1743-1-git-send-email-himanshujha199640@gmail.com> From: Kees Cook Date: Thu, 8 Mar 2018 11:39:15 -0800 X-Google-Sender-Auth: MfNKLbatTCj1-nxqquD4poU7QkA Message-ID: Subject: Re: [PATCH] iio: potentiometer: ds1803: Remove VLA usage To: Himanshu Jha Cc: jic23@kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, LKML , "Gustavo A. R. Silva" 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 Thu, Mar 8, 2018 at 10:45 AM, Himanshu Jha wrote: > In preparation to enabling -Wvla, remove VLA usage and replace it > with fixed a fixed length array and therefore, prevent potential > stack overflow attacks. > > Fixed as a part of the discussion to remove all VLAs from the kernel: > https://lkml.org/lkml/2018/3/7/621 > > Cc: keescook@chromium.org > Signed-off-by: Himanshu Jha > --- > drivers/iio/potentiometer/ds1803.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c > index 9b0ff4a..6bf12c9 100644 > --- a/drivers/iio/potentiometer/ds1803.c > +++ b/drivers/iio/potentiometer/ds1803.c > @@ -64,7 +64,7 @@ static int ds1803_read_raw(struct iio_dev *indio_dev, > struct ds1803_data *data = iio_priv(indio_dev); > int pot = chan->channel; > int ret; > - u8 result[indio_dev->num_channels]; > + u8 result[ARRAY_SIZE(ds1803_channels)]; It seems like num_channels is always ARRAY_SIZE(ds1803_channels). Could the entire field be dropped? -Kees > > switch (mask) { > case IIO_CHAN_INFO_RAW: > -- > 2.7.4 > -- Kees Cook Pixel Security