Path: csiph.com!news.freedyn.net!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod From: Vegard Nossum Newsgroups: linux.kernel Subject: Re: [PATCH] firmware: declare __{start,end}_builtin_fw as pointers Date: Sat, 25 Jun 2016 23:10:01 +0200 Message-ID: References: X-Original-To: Vegard Nossum Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GIbBtT2TmZcZCQmodPuSqnJJkdy1PAQhJ3bXA/lxlBo=; b=v4BQXZg6BzjNM1NsjCehl75xWrpJrI2dvFcPG1TKrjqMDlYDQKeSE/wxRQpXKgL8Tu Z5G+XVlRAsWhbJvxUAWMI5v4m0ip4cMI3LyPky0vre7R6RG9CeMQwKdFC/0tUASfexQX dc8ddMuNNiLDnpFQn///FB6F/wCv3lkoWtF7cBgUDBQRzlhnkr6NWMbAHYUkHBzhHPhI 4DyEgc7spZDw4pG4MJnJuo6+teksDP339dgtdo7ofvD5Ldo9gVyzabWfjQaitkNEMqSv 5fomcFx5ys3rAtkK2XYfjXWoGXMYSpMQr0RoEm4lEi9J/0baDck6Sp8EpOVl7zVEnwCK +9TQ== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GIbBtT2TmZcZCQmodPuSqnJJkdy1PAQhJ3bXA/lxlBo=; b=R/4NgoSqFDh7WODCIWhwlC1wqVfPu6FDnDSNwsQ7eBJf9hWNYLfS2goeE/RSKAJAi6 8B+MuLmkk2SfW73jBo5Nn5CaVsrJZTMW9SQU49K1uMIhRAcl7c2hwgdAN1gOAccYRMc6 htAt8HjDgbh4TqhI+YhK8EEbnhecxbx00yTHIP0VjUX061oNWZ5akK97DSM2tYRBz16y JndxY1tKmdcvOWr0D5mMqSq6pzCSe0SoGhJydjLFvK3J2o3j3ZrDKiaWrIfLCpMC7SQ+ JcZY1bFME5CKpI6k74nGv322yR0hgHbmTz36tgyRDGjHBH/K0EE0r0K1x5OnQlHH7lq3 xZeA== X-Gm-Message-State: ALyK8tIyDSu9P5mNUdl8j+jpJUg3FKvaE+4Xtu4zqHv2oKgAp3yr0dh3StaAilmkQUAWu/DP6yyGWODTxDsFyg== X-Received: by 10.31.92.77 with SMTP id q74mr5249723vkb.92.1466888804105; Sat, 25 Jun 2016 14:06:44 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 32 Organization: linux.* mail to news gateway X-Original-Cc: Ming Lei , LKML X-Original-Date: Sat, 25 Jun 2016 23:06:43 +0200 X-Original-Message-ID: X-Original-References: <1466867073-4824-1-git-send-email-vegard.nossum@oracle.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1431216 On 25 June 2016 at 17:04, Vegard Nossum wrote: > The test in this loop: > > for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { > > was getting completely compiled out by my gcc, 7.0.0 20160520. The result > was that the loop was going beyond the end of the builtin_fw array and > giving me a page fault when trying to dereference b_fw->name inside > strcmp(). > > I strongly suspect it's because __start_builtin_fw and __end_builtin_fw > are both declared as (separate) arrays, and so gcc conludes that b_fw can > never point to __end_builtin_fw. > > By changing these variables from arrays to pointers, gcc can no longer > assume that these are separate arrays. > > Cc: stable@vger.kernel.org > Signed-off-by: Vegard Nossum Actually, the analysis seems right (by inspection of the assembly code), but the patch is wrong and causes another crash as the variables are not really pointers but true arrays (i.e. the linker script provides the address of the variable, not its value). I see the __start_foo[]/__end_foo[] idiom is used a lot in the kernel so this could potentially be a problem in other places as well. The best solution may be a compiler flag (if it exists). I'll play a bit more with it to see if I can come up with something. Vegard