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] [day] [month] [year] [list]
Message-ID: <3d476a88ffc6486099dd29acdd242436@AcuMS.aculab.com>
Date:   Thu, 16 May 2019 09:08:15 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Linus Torvalds' <torvalds@...ux-foundation.org>,
        Steven Rostedt <rostedt@...dmis.org>
CC:     LKML <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: RE: [GIT PULL] tracing: Updates for 5.2

> This code:
> 
>                 /* reset all but tr, trace, and overruns */
>                 memset(&iter.seq, 0,
>                        sizeof(struct trace_iterator) -
>                        offsetof(struct trace_iterator, seq));
> 
> not only has a completely misleading comment (it resets a lot more
> than the comment states), but modern gcc looks at that code and says
> "oh, you're passing it a pointer to 'iter.seq', but then clearing a
> lot more than a 'trace_seq'":
> 
>   In function ‘memset’,
>       inlined from ‘ftrace_dump’ at kernel/trace/trace.c:8914:3:
>  /include/linux/string.h:344:9: warning: ‘__builtin_memset’ offset
> [8505, 8560] from the object at ‘iter’ is out of the bounds of
> referenced subobject ‘seq’ with type ‘struct trace_seq’ at offset 4368
> [-Warray-bounds]
>     344 |  return __builtin_memset(p, c, size);
>         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> It's a somewhat annoying warning because the code itself is
> technically correct, but at the same time, I think the gcc warning is
> reasonable. You *are* passing it a 'struct trace_seq' pointer, and
> then you're clearing a whole lot more than that.
> 
> One option is to just rewrite it something like
> 
>         const unsigned int offset = offsetof(struct trace_iterator, seq);
>         memset(offset+(void *)&iter, 0, sizeof(iter) - offset);

I'd do (const char *)&iter + offset ...

A quick fix is (probably) just:
	memset((void *)(long)&iter.seq, ...

	David

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ