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: <CALCETrX6Nt3LFE=dC+9rZ1b5n_tW0b5f9Uo3aTydp1tcqLzzLg@mail.gmail.com>
Date:	Mon, 9 Mar 2015 07:20:24 -0700
From:	Andy Lutomirski <luto@...capital.net>
To:	Denys Vlasenko <vda.linux@...glemail.com>
Cc:	Denys Vlasenko <dvlasenk@...hat.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
	"H. Peter Anvin" <hpa@...or.com>, Oleg Nesterov <oleg@...hat.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Alexei Starovoitov <ast@...mgrid.com>,
	Will Drewry <wad@...omium.org>,
	Kees Cook <keescook@...omium.org>, X86 ML <x86@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86: make 32-bit "emergency stack" better documented

On Mon, Mar 9, 2015 at 7:14 AM, Denys Vlasenko <vda.linux@...glemail.com> wrote:
> On Mon, Mar 9, 2015 at 2:43 PM, Andy Lutomirski <luto@...capital.net> wrote:
>>>         /* Offset from the sysenter stack to tss.sp0 */
>>>         DEFINE(TSS_sysenter_sp0, offsetof(struct tss_struct, x86_tss.sp0) -
>>> -                sizeof(struct tss_struct));
>>> +               (offsetof(struct tss_struct, SYSENTER_stack_last_word) + 4));
>>
>> Is there no way to do this using sizeof to avoid having a "last_word" member.
>
> sizeof of a structure member? IIRC in C sizeof can't be used for that.
> You need to concoct a fictitious object, dereference its member
> and take sizeof of _that_.
>
> It would look horrible. Something like:
>
> offsetof(struct tss_struct, SYSENTER_stack) +
>                 sizeof(((struct tss_struct*)NULL)->SYSENTER_stack)

vfio.h has:

/**
 * offsetofend(TYPE, MEMBER)
 *
 * @TYPE: The type of the structure
 * @MEMBER: The member within the structure to get the end offset of
 *
 * Simple helper macro for dealing with variable sized structures passed
 * from user space.  This allows us to easily determine if the provided
 * structure is sized to include various fields.
 */
#define offsetofend(TYPE, MEMBER) \
        (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))

we could stick that in stdef.h and use it.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ