Received: by 10.223.185.111 with SMTP id b44csp170854wrg; Fri, 9 Mar 2018 03:07:00 -0800 (PST) X-Google-Smtp-Source: AG47ELtApGR3BAJFxOsl3AUlbLPV8eCEWJv3XX5nwhCra9JOpJ4vNkvGvv8u6vNJ8wjDoi+IaHtG X-Received: by 10.98.162.26 with SMTP id m26mr29695341pff.217.1520593620725; Fri, 09 Mar 2018 03:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520593620; cv=none; d=google.com; s=arc-20160816; b=FWFENaYOaEqyWQq9gm++wPE/gH0DC/Xi+FJUos3Ul9ibaORD/vex4jk1NswlyzflCB 4ME5QeZzPwIlTZFfOl6OTG2dswilQQqcGgEzpnQjRRcuq98AkJF6wrDSApJSmUDGoN2t Tt0hCocHlhO/DvHHWS2MYjQ0/MzRLSMO6N7o8kGS+0lfH8MZcKGRH3UU8//x9XBT6rdX NjEiCqRc2ssOJybChVG6g/V7eZX1D0r+HrD5wtAUhobcTWFvNVF+aX+3GxEAdSTX5PDe JiKpX99K7wtaA8qIbHsRSJIu4uc39gXZSK4kGuMOCHnHYkIU+JBxeKOr0FSfc1aztLub bkjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=A3JCdD0f8P2kvJYjjh204w85gxjUa3Gscfw9cV2aTrM=; b=CM2cRjRfJpBkaovrok6kdRvfw0KLVPRQTE/GpDaT92B83pNPEOYjgoL7IqyH17lBF7 Pnvvzb5TWmblfcYOZYZb62RlUzm7ygZXi6dxv3wQyexJqp+/coaaBpqw7mEU3fgEEOVX BQLvQAw/TFQKuDcVQXSYztZOJ0sVp49ZaRnkJP9pACotJYbFooY0S1cW29qFy4fLXV0U 5AxeaMpwMVnCB8qKV+mgpLAYECTxdMkFvx/HHkO2BgeXsgaJBmT6LFYs+K0sEMT9Q4jH pg/4pfbMZSeMB7q5RBcVHNigxDtQkyRK292Baro3MuTkMlYUciWuyidE7oTTz1+ShHyd D5bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SVC1Esrm; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y64si557367pgy.363.2018.03.09.03.06.46; Fri, 09 Mar 2018 03:07:00 -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=pass header.i=@gmail.com header.s=20161025 header.b=SVC1Esrm; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751190AbeCILFV (ORCPT + 99 others); Fri, 9 Mar 2018 06:05:21 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:44923 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751025AbeCILFT (ORCPT ); Fri, 9 Mar 2018 06:05:19 -0500 Received: by mail-pf0-f196.google.com with SMTP id 17so1137014pfw.11; Fri, 09 Mar 2018 03:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=A3JCdD0f8P2kvJYjjh204w85gxjUa3Gscfw9cV2aTrM=; b=SVC1EsrmktYDBF7EpNQi1Gt+mn4gh81jZxqjkI9pcC4OayA9OMvRAEMNY22Jb/9as3 skfOEcB7LeW1rGgDcEYOiZvv5QDnptN9fiWgziO5NtCJjFzZqyV0b7JdPk9Jbiel4ZWi iDUZblo+swCv14k1xLGZw/8mAhhQrKemeed3caUmGU2JZQ4nommbWnKJiXH5DjYEHL4F fmywHAEindnUYJAERJFskwj55/3ePl/vPKVXc3WupKzUJoaKKO/I07w8/bAeFAkDayCU KZYfE0kHXyeXhewHfhgjW7+H4IQsLUY++qJJYxQ3VnoVktsOmEdScKYj0ubVUfitPjSB ZOpw== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=A3JCdD0f8P2kvJYjjh204w85gxjUa3Gscfw9cV2aTrM=; b=h3tU6cWBpn8jAkmom9lwmMDAryhHtqqC95UVuRl5/VgDzC2/ehK3X7JghE/C+bESJy GiJ2+F3/6dOVr+GU2tfVY1XxpnEg+Yp6Bl/MN1lkT0kJPFYeGXqNQX2syUQXbhbatJBl 4drbqySBpCI3FRbSw5KCpMn0Pby4io/I0arMCpM/tO1ijRN1x0bJ+4MPMvG4nQKQGua1 ulf5MSf9Rx8FOOJJOfaXTeXy245MyHl4CBj/t1Hnyghp4KzByYT26W2vcrtLaZlHC1Xf /j0szBTSQRECwbulBTCVTFAwDo5XxOHwBmEchf4YEqrEk9tK3Kf5qeTz3SznVt2j7jw1 UyaA== X-Gm-Message-State: APf1xPD6AOD/TPFgC0rqMPqgLY88VfUnH5hbHEM62quwr3UgnXcHYRz9 HmQ/Wru96OEyRfiZDqkBDF2akA== X-Received: by 10.99.112.20 with SMTP id l20mr24438722pgc.412.1520593518768; Fri, 09 Mar 2018 03:05:18 -0800 (PST) Received: from himanshu-Vostro-3559 ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id d64sm2337260pfa.118.2018.03.09.03.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 03:05:18 -0800 (PST) Date: Fri, 9 Mar 2018 16:35:10 +0530 From: Himanshu Jha To: Kees Cook Cc: jic23@kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, LKML , "Gustavo A. R. Silva" Subject: Re: [PATCH] iio: potentiometer: ds1803: Remove VLA usage Message-ID: <20180309110510.GB7786@himanshu-Vostro-3559> References: <1520534733-1743-1-git-send-email-himanshujha199640@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 08, 2018 at 11:39:15AM -0800, Kees Cook wrote: > 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? If you're asking to remove num_channels then certainly it is not possible since it is a member of industrial I/O device struct and it is not just a member of regular struct local to this file. We certainly know that there are only two channels BTW and it can be tranformed to simply: u8 result[2]; But then I might have to add an additional comment explaining the magic number 2. -- Thanks Himanshu Jha