From patchwork Fri Mar 9 06:11:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tycho Andersen X-Patchwork-Id: 10269757 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 8802C602BD for ; Fri, 9 Mar 2018 06:12:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E3D729CB9 for ; Fri, 9 Mar 2018 06:12:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62F6429CC0; Fri, 9 Mar 2018 06:12:14 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 8A77A29CB9 for ; Fri, 9 Mar 2018 06:12:13 +0000 (UTC) Received: (qmail 19890 invoked by uid 550); 9 Mar 2018 06:12:10 -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 19847 invoked from network); 9 Mar 2018 06:12:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EDneMGqUojeg0nwgVDpADrWOyvGBlsyC2CcOqv6M744=; b=CMKqNs0eZh526yQvbAukv6soj3/OSkj3iqwrv+7wr0xxUqclKYf7vYC4Oq3efWa6Zb M9MXET9+VKubEhfqKUacPOXyCHJxeXoK27SdosYXILfM0WRvgNjQpMveU7HAHcnMg2ZH dQfORzlk9zqRRnfJ6Jg+mZIKHtkidMY0pdkDonbMXq0IlJ1i0Tu6k3fQ3Ndy2ZfNXOuw jJCGUZ/e6nssM1zRXc2H/qXHpT82lcxR1E60KrYEfsECFk4b/1AK6b2ZlF8OtjRDrafe PYdKdXCE/6DHGB3UUm6x6rOqmBsWAxeCYsZD7mEBT7Xavp5Bf2zVLHlDLvcNTBnu/spa kDmQ== 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=EDneMGqUojeg0nwgVDpADrWOyvGBlsyC2CcOqv6M744=; b=CIngqJEC7T6U1QwnB+XNpZKHr5oJZZmrXJ+nIw9NUGL3TZLHrgYzIjYLOT9sOBMbBU U++aegESPNpKCB4j/+746U48HCu6C5eyIq0hxxZwYbbnWxLlCuusIocbnK7F4+UtG9j2 RvId7AfUXDdPUSjCI3r6wBCGZFfAiR8h2t09a8md83UfMWJnqadQWeeucb5zgtvjii77 NmVc6DUatVLpJmBnl6egwnDYYE/thU6K0D7RUW+w/7lbgu9rFL9A5UKUq9VZiWY+6Dm6 KXgdCzy2IUPa3LNCESOjBR9+pMsnvGIS5t8cCbPL/wjD1Hq/9kPJCEC3B5ZpN+7O3LHg SEpw== X-Gm-Message-State: APf1xPBaBViK2mgpiBJCJoXX9cFe2JKafmQf7tfRk9HcC/dQeXkmQjWB 33U1pcB4gOhymBKRPAf9sv0tpg== X-Google-Smtp-Source: AG47ELvn9FA60kqwmDKfC5yzsTTuXdw3/nE+j4J6sZqkSeRL2zFXwF76CHoTNaDutWjZYapziFdp+w== X-Received: by 2002:a17:902:d891:: with SMTP id b17-v6mr25903008plz.241.1520575917289; Thu, 08 Mar 2018 22:11:57 -0800 (PST) Date: Thu, 8 Mar 2018 23:11:52 -0700 From: Tycho Andersen To: Joe Perches Cc: "Tobin C. Harding" , Florian Tobias Schandinat , Bartlomiej Zolnierkiewicz , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, driverdev-devel@linuxdriverproject.org, Kees Cook Subject: Re: [PATCH 4/4] video: Remove stack VLA usage Message-ID: <20180309061152.r3yumh6agasyhtvo@cisco> References: <1520574625-4225-1-git-send-email-me@tobin.cc> <1520575267.11634.25.camel@perches.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1520575267.11634.25.camel@perches.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Mar 08, 2018 at 10:01:07PM -0800, Joe Perches wrote: > On Fri, 2018-03-09 at 16:50 +1100, Tobin C. Harding wrote: > > The kernel would like to have all stack VLA usage removed[1]. The > > arrays are fixed here (declared with a const variable) but they appear > > like VLAs to the compiler. We can use a pre-processor define to fix the > > warning. > [] > > diff --git a/drivers/video/fbdev/via/via_aux_sii164.c b/drivers/video/fbdev/via/via_aux_sii164.c > [] > > @@ -27,6 +27,9 @@ > > > > static const char *name = "SiI 164 PanelLink Transmitter"; > > > > +/* check vendor id and device id */ > > +const u8 id[] = {0x01, 0x00, 0x06, 0x00}; > > It seems id is now global in multiple places. > Perhaps these should be static. Does it even need to be global? Why not just get rid of the indirection and use ARRAY_SIZE where we mean it? This seems to work for me, Cheers, Tycho diff --git a/drivers/video/fbdev/via/via_aux_sii164.c b/drivers/video/fbdev/via/via_aux_sii164.c index ca1b35f033b1..87db6c98d680 100644 --- a/drivers/video/fbdev/via/via_aux_sii164.c +++ b/drivers/video/fbdev/via/via_aux_sii164.c @@ -35,10 +35,10 @@ static void probe(struct via_aux_bus *bus, u8 addr) .addr = addr, .name = name}; /* check vendor id and device id */ - const u8 id[] = {0x01, 0x00, 0x06, 0x00}, len = ARRAY_SIZE(id); - u8 tmp[len]; + const u8 id[] = {0x01, 0x00, 0x06, 0x00}; + u8 tmp[ARRAY_SIZE(id)]; - if (!via_aux_read(&drv, 0x00, tmp, len) || memcmp(id, tmp, len)) + if (!via_aux_read(&drv, 0x00, tmp, sizeof(tmp)) || memcmp(id, tmp, sizeof(tmp))) return; printk(KERN_INFO "viafb: Found %s at address 0x%x\n", name, addr);