Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'hardening-v6.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull hardening fix from Kees Cook:

- stddef: make __struct_group() UAPI C++-friendly (Alexander Lobakin)

* tag 'hardening-v6.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
stddef: make __struct_group() UAPI C++-friendly

+21 -7
+10 -3
include/uapi/linux/stddef.h
··· 8 8 #define __always_inline inline 9 9 #endif 10 10 11 + /* Not all C++ standards support type declarations inside an anonymous union */ 12 + #ifndef __cplusplus 13 + #define __struct_group_tag(TAG) TAG 14 + #else 15 + #define __struct_group_tag(TAG) 16 + #endif 17 + 11 18 /** 12 19 * __struct_group() - Create a mirrored named and anonyomous struct 13 20 * ··· 27 20 * and size: one anonymous and one named. The former's members can be used 28 21 * normally without sub-struct naming, and the latter can be used to 29 22 * reason about the start, end, and size of the group of struct members. 30 - * The named struct can also be explicitly tagged for layer reuse, as well 31 - * as both having struct attributes appended. 23 + * The named struct can also be explicitly tagged for layer reuse (C only), 24 + * as well as both having struct attributes appended. 32 25 */ 33 26 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ 34 27 union { \ 35 28 struct { MEMBERS } ATTRS; \ 36 - struct TAG { MEMBERS } ATTRS NAME; \ 29 + struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \ 37 30 } ATTRS 38 31 39 32 #ifdef __cplusplus
+11 -4
tools/include/uapi/linux/stddef.h
··· 8 8 #define __always_inline __inline__ 9 9 #endif 10 10 11 + /* Not all C++ standards support type declarations inside an anonymous union */ 12 + #ifndef __cplusplus 13 + #define __struct_group_tag(TAG) TAG 14 + #else 15 + #define __struct_group_tag(TAG) 16 + #endif 17 + 11 18 /** 12 19 * __struct_group() - Create a mirrored named and anonyomous struct 13 20 * ··· 27 20 * and size: one anonymous and one named. The former's members can be used 28 21 * normally without sub-struct naming, and the latter can be used to 29 22 * reason about the start, end, and size of the group of struct members. 30 - * The named struct can also be explicitly tagged for layer reuse, as well 31 - * as both having struct attributes appended. 23 + * The named struct can also be explicitly tagged for layer reuse (C only), 24 + * as well as both having struct attributes appended. 32 25 */ 33 26 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ 34 27 union { \ 35 28 struct { MEMBERS } ATTRS; \ 36 - struct TAG { MEMBERS } ATTRS NAME; \ 37 - } 29 + struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \ 30 + } ATTRS 38 31 39 32 /** 40 33 * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union