lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190122093313.67375948@bbrezillon>
Date:   Tue, 22 Jan 2019 09:33:13 +0100
From:   Boris Brezillon <bbrezillon@...nel.org>
To:     Miquel Raynal <miquel.raynal@...tlin.com>
Cc:     Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Lucas Stach <dev@...xeye.de>,
        Marek Vasut <marek.vasut@...il.com>,
        Richard Weinberger <richard@....at>,
        Linus Walleij <linus.walleij@...aro.org>,
        Janusz Krzysztofik <jmkrzyszt@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Stefan Agner <stefan@...er.ch>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Boris Brezillon <boris.brezillon@...tlin.com>,
        Thierry Reding <thierry.reding@...il.com>,
        linux-mtd <linux-mtd@...ts.infradead.org>,
        linux-tegra@...r.kernel.org,
        Brian Norris <computersforpeace@...il.com>,
        David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH 2/2] mtd: rawnand: use unnamed union in struct
 nand_op_parser_pattern_elem

On Tue, 22 Jan 2019 09:08:30 +0100
Miquel Raynal <miquel.raynal@...tlin.com> wrote:

> Hi Masahiro,
> 
> Masahiro Yamada <yamada.masahiro@...ionext.com> wrote on Tue, 22 Jan
> 2019 17:00:54 +0900:
> 
> > On Tue, Jan 22, 2019 at 4:50 PM Miquel Raynal <miquel.raynal@...tlin.com> wrote:  
> > >
> > > Hi Masahiro,
> > >
> > > Masahiro Yamada <yamada.masahiro@...ionext.com> wrote on Tue, 22 Jan
> > > 2019 16:42:55 +0900:
> > >    
> > > > Although drivers do not directly get access to the private data of
> > > > instruction patterns, let's use unnamed union field to be consistent
> > > > with nand_op_instr.
> > > >    
> > >
> > > Actually this is how we wrote it the first time. Then we got robots
> > > reporting that anonymous unions where not allowed with older (still
> > > supported) GCC versions and I had to do this:
> > >
> > >
> > > commit c1a72e2dbb4abb90bd408480d7c48ba40cb799ce
> > > Author: Miquel Raynal <miquel.raynal@...e-electrons.com>
> > > Date:   Fri Jan 19 19:11:27 2018 +0100
> > >
> > >     mtd: nand: Fix build issues due to an anonymous union
> > >
> > >     GCC-4.4.4 raises errors when assigning a parameter in an anonymous
> > >     union, leading to this kind of failure:
> > >
> > >     drivers/mtd/nand/marvell_nand.c:1936:
> > >         warning: missing braces around initializer
> > >         warning: (near initialization for '(anonymous)[1].<anonymous>')
> > >         error: unknown field 'data' specified in initializer
> > >         error: unknown field 'addr' specified in initializer
> > >
> > >     Work around the situation by naming these unions.
> > >
> > >     Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
> > >     Reported-by: Andrew Morton <akpm@...ux-foundation.org>
> > >     Signed-off-by: Miquel Raynal <miquel.raynal@...e-electrons.com>
> > >     Tested-by: Andrew Morton <akpm@...ux-foundation.org>
> > >     Signed-off-by: Boris Brezillon <boris.brezillon@...e-electrons.com>
> > >    
> > 
> > 
> > Hmm, how come Andrew's compiler was fine with the following?
> > 
> > struct nand_flash_dev {
> >         char *name;
> >         union {
> >                 struct {
> >                         uint8_t mfr_id;
> >                         uint8_t dev_id;
> >                 };
> >                 uint8_t id[NAND_MAX_ID_LEN];
> >         };
> >         unsigned int pagesize;
> >         ...
> > };
> >   
> 
> It is probably not :)

It was compile fine. I don't know all the subtleties, but maybe it's
because ->id[] is a base type and not a struct.

> 
> > 
> > 
> > The current minimum version is GCC 4.6
> > (commit cafa0010cd51fb7)
> > but I am not sure if this restriction is remaining.
> >   
> 
> That's right, can you please test if this limitation is still
> ongoing wit GCC 4.6?

I have a more important question: why should we go bad back to unnamed
unions? Why is that a problem to have a named union? Sure, we initially
started with an unnamed ones because it made lines shorter, but now that
we switched to named unions I don't see the point of going back and
patching all drivers again (at the risk of seeing this problem appear
again when compiled with an old compiler version).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ