[lkml]   [2018]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH] KEYS: trusted: fix -Wvarags warning
> 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 ( and C11 (
> 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.


Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
 \ /
  Last update: 2018-10-15 11:26    [W:0.174 / U:3.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site