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] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7d202457150472588df0bd3b7334b3f@AcuMS.aculab.com>
Date:   Mon, 1 Aug 2022 07:46:22 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Steven Rostedt' <rostedt@...dmis.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Ingo Molnar <mingo@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: RE: [for-next][PATCH 21/21] tracing: Use a struct alignof to
 determine trace event field alignment

From: Steven Rostedt
> Sent: 31 July 2022 20:04
> 
> alignof() gives an alignment of types as they would be as standalone
> variables. But alignment in structures might be different, and when
> building the fields of events, the alignment must be the actual
> alignment otherwise the field offsets may not match what they actually
> are.
> 
> This caused trace-cmd to crash, as libtraceevent did not check if the
> field offset was bigger than the event. The write_msr and read_msr
> events on 32 bit had their fields incorrect, because it had a u64 field
> between two ints. alignof(u64) would give 8, but the u64 field was at a
> 4 byte alignment.
> 
> Define a macro as:
> 
>    ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))
> 
> which gives the actual alignment of types in a structure.

The simpler:
	__alignof__(struct {type b;})
also works.

	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