[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0147a993d4a94426afa469a8dcc4e5d7@AcuMS.aculab.com>
Date: Tue, 16 Oct 2018 08:13:25 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Nick Desaulniers' <ndesaulniers@...gle.com>
CC: "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
"dhowells@...hat.com" <dhowells@...hat.com>,
Nathan Chancellor <natechancellor@...il.com>,
"Eric Biggers" <ebiggers@...gle.com>,
"zohar@...ux.vnet.ibm.com" <zohar@...ux.vnet.ibm.com>,
"jmorris@...ei.org" <jmorris@...ei.org>,
"serge@...lyn.com" <serge@...lyn.com>,
"linux-integrity@...r.kernel.org" <linux-integrity@...r.kernel.org>,
"keyrings@...r.kernel.org" <keyrings@...r.kernel.org>,
"linux-security-module@...r.kernel.org"
<linux-security-module@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] KEYS: trusted: fix -Wvarags warning
From: Nick Desaulniers
> Sent: 15 October 2018 22:54
> On Mon, Oct 15, 2018 at 2:26 AM David Laight <David.Laight@...lab.com> wrote:
> >
> > From: ndesaulniers@...gle.com
> > > Sent: 11 October 2018 21:31
> > ...
> > > by swapping h2 and h3.
> > >
> > > security/keys/trusted.c:146:17: warning: passing an object that
> > > undergoes default
> > > argument promotion to 'va_start' has undefined behavior [-Wvarargs]
> > > va_start(argp, h3);
> > > ^
> > > security/keys/trusted.c:126:37: note: parameter of type 'unsigned
> > > char' is declared here
> > > unsigned char *h2, unsigned char h3, ...)
> > > ^
> > > Specifically, it seems that both the C90 (4.8.1.1) and C11 (7.16.1.4)
> > > standards explicitly call this out as undefined behavior:
> >
> > I guess that problems arise when all the arguments are stacked
> > and va_start/va_arg use naive pointer manipulation.
> > In that case &h3 might be 4n+3 aligned so va_arg() will access
> > misaligned stack locations.
> >
> > I doubt any modern compilers (where va_start and va_arg are builtins)
> > will get this 'wrong' even when all arguments are stacked.
> >
> > Seems clang is being over cautious.
>
> Yes; did you have feedback on the Denis' proposed fix, or another?
Personally I'd avoid char, short and bool for both function
arguments and results since they typically require extra
instructions for masking values (etc).
bool is particularly obnoxious.
In that case either int or unsigned int is good.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists