From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f171.google.com ([209.85.215.171]:36748 "EHLO mail-pg1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbeJPFlH (ORCPT ); Tue, 16 Oct 2018 01:41:07 -0400 Received: by mail-pg1-f171.google.com with SMTP id f18-v6so9802474pgv.3 for ; Mon, 15 Oct 2018 14:54:01 -0700 (PDT) MIME-Version: 1.0 References: <1539274203.2623.56.camel@linux.vnet.ibm.com> <20181011203126.15338-1-ndesaulniers@google.com> <0180360cfcb5458d8ff099744e8884d4@AcuMS.aculab.com> In-Reply-To: <0180360cfcb5458d8ff099744e8884d4@AcuMS.aculab.com> From: Nick Desaulniers Date: Mon, 15 Oct 2018 14:53:49 -0700 Message-ID: Subject: Re: [PATCH] KEYS: trusted: fix -Wvarags warning To: David.Laight@aculab.com Cc: "James E.J. Bottomley" , dhowells@redhat.com, Nathan Chancellor , Eric Biggers , zohar@linux.vnet.ibm.com, jmorris@namei.org, serge@hallyn.com, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-integrity-owner@vger.kernel.org List-ID: On Mon, Oct 15, 2018 at 2:26 AM David Laight wrote: > > From: ndesaulniers@google.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? > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) -- Thanks, ~Nick Desaulniers