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: <ec5747cf-0222-42eb-91fa-e67c4c0f3f61@mev.co.uk>
Date:   Tue, 23 May 2017 13:02:59 +0100
From:   Ian Abbott <abbotti@....co.uk>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Michal Nazarewicz <mina86@...a86.com>,
        linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Hidehiro Kawai <hidehiro.kawai.ez@...achi.com>,
        Borislav Petkov <bp@...e.de>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Johannes Berg <johannes.berg@...el.com>,
        Alexander Potapenko <glider@...gle.com>
Subject: Re: [PATCH v2] kernel.h: handle pointers to arrays better in
 container_of()

On 23/05/17 12:24, Peter Zijlstra wrote:
> On Tue, May 23, 2017 at 11:32:02AM +0100, Ian Abbott wrote:
>
>>> #define container_of(ptr, type, member) (				\
>>> 	_Static_assert(__builtin_types_compatible_p(			\
>>>             typeof(*ptr), typeof( ((type *)0)->member )), "WUT"),	\
>>> 	((type *)((char *)(ptr) - offsetof(type, member)));		\
>>> )
>>
>> It's a fine suggestion (if more parentheses are added), but _Static_assert
>> is a C11 feature, and I thought the kernel was using gnu89 (unless it's been
>> updated since).
>
> We have BUILD_BUG_ON() that should be similar in functionality.

Yes, I think BUILD_BUG_ON_ZERO() will be better in this case to avoid 
some baggage.  Also, __same_type() can be used for type checking.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@....co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ