All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'ndesaulniers@google.com'" <ndesaulniers@google.com>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"dhowells@redhat.com" <dhowells@redhat.com>
Cc: "natechancellor@gmail.com" <natechancellor@gmail.com>,
	"ebiggers@google.com" <ebiggers@google.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
	"linux-security-module@vger.kernel.org"
	<linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] KEYS: trusted: fix -Wvarags warning
Date: Mon, 15 Oct 2018 09:26:02 +0000	[thread overview]
Message-ID: <0180360cfcb5458d8ff099744e8884d4@AcuMS.aculab.com> (raw)
In-Reply-To: <20181011203126.15338-1-ndesaulniers@google.com>

RnJvbTogbmRlc2F1bG5pZXJzQGdvb2dsZS5jb20NCj4gU2VudDogMTEgT2N0b2JlciAyMDE4IDIx
OjMxDQouLi4NCj4gYnkgc3dhcHBpbmcgaDIgYW5kIGgzLg0KPiANCj4gc2VjdXJpdHkva2V5cy90
cnVzdGVkLmM6MTQ2OjE3OiB3YXJuaW5nOiBwYXNzaW5nIGFuIG9iamVjdCB0aGF0DQo+IHVuZGVy
Z29lcyBkZWZhdWx0DQo+ICAgICAgIGFyZ3VtZW50IHByb21vdGlvbiB0byAndmFfc3RhcnQnIGhh
cyB1bmRlZmluZWQgYmVoYXZpb3IgWy1XdmFyYXJnc10NCj4gICAgICAgICB2YV9zdGFydChhcmdw
LCBoMyk7DQo+ICAgICAgICAgICAgICAgICAgICAgICAgXg0KPiBzZWN1cml0eS9rZXlzL3RydXN0
ZWQuYzoxMjY6Mzc6IG5vdG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ykNCg=

WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: "'ndesaulniers@google.com'" <ndesaulniers@google.com>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"dhowells@redhat.com" <dhowells@redhat.com>
Cc: "natechancellor@gmail.com" <natechancellor@gmail.com>,
	"ebiggers@google.com" <ebiggers@google.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
	"linux-security-module@vger.kernel.org" 
	<linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] KEYS: trusted: fix -Wvarags warning
Date: Mon, 15 Oct 2018 09:26:02 +0000	[thread overview]
Message-ID: <0180360cfcb5458d8ff099744e8884d4@AcuMS.aculab.com> (raw)
In-Reply-To: <20181011203126.15338-1-ndesaulniers@google.com>

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.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: "'ndesaulniers@google.com'" <ndesaulniers@google.com>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"dhowells@redhat.com" <dhowells@redhat.com>
Cc: "natechancellor@gmail.com" <natechancellor@gmail.com>,
	"ebiggers@google.com" <ebiggers@google.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
	"linux-security-module@vger.kernel.org"
	<linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] KEYS: trusted: fix -Wvarags warning
Date: Mon, 15 Oct 2018 09:26:02 +0000	[thread overview]
Message-ID: <0180360cfcb5458d8ff099744e8884d4@AcuMS.aculab.com> (raw)
In-Reply-To: <20181011203126.15338-1-ndesaulniers@google.com>

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.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2018-10-15  9:26 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 22:11 undefined behavior (-Wvarargs) in security/keys/trusted.c#TSS_authhmac() Nick Desaulniers
2018-10-09 22:11 ` Nick Desaulniers
2018-10-11 16:02 ` Arnd Bergmann
2018-10-11 16:02   ` Arnd Bergmann
2018-10-11 16:10   ` James Bottomley
2018-10-11 16:10     ` James Bottomley
2018-10-11 20:31     ` [PATCH] KEYS: trusted: fix -Wvarags warning ndesaulniers
2018-10-11 20:31       ` ndesaulniers
2018-10-12  1:50       ` Nathan Chancellor
2018-10-12  1:50         ` Nathan Chancellor
2018-10-12 16:55         ` Nick Desaulniers
2018-10-12 16:55           ` Nick Desaulniers
2018-10-12 17:03           ` Nathan Chancellor
2018-10-12 17:03             ` Nathan Chancellor
2018-10-12 12:29       ` Denis Kenzior
2018-10-12 12:29         ` Denis Kenzior
2018-10-12 15:05         ` James Bottomley
2018-10-12 15:05           ` James Bottomley
2018-10-12 15:13           ` Denis Kenzior
2018-10-12 15:13             ` Denis Kenzior
2018-10-12 15:22             ` James Bottomley
2018-10-12 15:22               ` James Bottomley
2018-10-12 15:44               ` Denis Kenzior
2018-10-12 15:44                 ` Denis Kenzior
2018-10-12 15:46                 ` James Bottomley
2018-10-12 15:46                   ` James Bottomley
2018-10-12 15:53                   ` Denis Kenzior
2018-10-12 15:53                     ` Denis Kenzior
2018-10-12 16:01                     ` James Bottomley
2018-10-12 16:01                       ` James Bottomley
2018-10-12 17:14                       ` Nick Desaulniers
2018-10-12 17:14                         ` Nick Desaulniers
2018-10-12 15:25             ` James Bottomley
2018-10-12 15:25               ` James Bottomley
2018-10-12 17:05             ` Nick Desaulniers
2018-10-12 17:05               ` Nick Desaulniers
2018-10-12 17:17               ` Nick Desaulniers
2018-10-12 17:17                 ` Nick Desaulniers
2018-10-12 17:27               ` Denis Kenzior
2018-10-12 17:27                 ` Denis Kenzior
2018-10-12 18:39                 ` Nick Desaulniers
2018-10-12 18:39                   ` Nick Desaulniers
2018-10-12 17:02         ` Nick Desaulniers
2018-10-12 17:02           ` Nick Desaulniers
2018-10-12 17:15           ` Denis Kenzior
2018-10-12 17:15             ` Denis Kenzior
2018-10-15  9:26       ` David Laight [this message]
2018-10-15  9:26         ` David Laight
2018-10-15  9:26         ` David Laight
2018-10-15 21:53         ` Nick Desaulniers
2018-10-15 21:53           ` Nick Desaulniers
2018-10-16  8:13           ` David Laight
2018-10-16  8:13             ` David Laight
2018-10-16  8:13             ` David Laight
2018-10-22 23:43             ` [PATCH v2] " ndesaulniers
2018-10-22 23:43               ` ndesaulniers
2018-10-23  0:00               ` Nathan Chancellor
2018-10-23  0:00                 ` Nathan Chancellor
2018-10-24  8:36               ` Jarkko Sakkinen
2018-10-24  8:36                 ` Jarkko Sakkinen
2018-10-29 17:54                 ` Nick Desaulniers
2018-10-29 17:54                   ` Nick Desaulniers
2019-02-11 18:36                   ` Nick Desaulniers
2019-02-11 18:36                     ` Nick Desaulniers
2019-02-12 23:12                     ` Jarkko Sakkinen
2019-02-12 23:12                       ` Jarkko Sakkinen
2019-02-14 10:52                       ` Jarkko Sakkinen
2019-02-14 10:52                         ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0180360cfcb5458d8ff099744e8884d4@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=dhowells@redhat.com \
    --cc=ebiggers@google.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.