public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Christopher Ferris <cferris@google.com>,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Kees Cook <kees@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 30/86] stddef: make __struct_group() UAPI C++-friendly
Date: Mon, 30 Dec 2024 16:42:38 +0100	[thread overview]
Message-ID: <20241230154212.867663436@linuxfoundation.org> (raw)
In-Reply-To: <20241230154211.711515682@linuxfoundation.org>

6.6-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexander Lobakin <aleksander.lobakin@intel.com>

[ Upstream commit 724c6ce38bbaeb4b3f109b0e066d6c0ecd15446c ]

For the most part of the C++ history, it couldn't have type
declarations inside anonymous unions for different reasons. At the
same time, __struct_group() relies on the latters, so when the @TAG
argument is not empty, C++ code doesn't want to build (even under
`extern "C"`):

../linux/include/uapi/linux/pkt_cls.h:25:24: error:
'struct tc_u32_sel::<unnamed union>::tc_u32_sel_hdr,' invalid;
an anonymous union may only have public non-static data members
[-fpermissive]

The safest way to fix this without trying to switch standards (which
is impossible in UAPI anyway) etc., is to disable tag declaration
for that language. This won't break anything since for now it's not
buildable at all.
Use a separate definition for __struct_group() when __cplusplus is
defined to mitigate the error, including the version from tools/.

Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
Reported-by: Christopher Ferris <cferris@google.com>
Closes: https://lore.kernel.org/linux-hardening/Z1HZpe3WE5As8UAz@google.com
Suggested-by: Kees Cook <kees@kernel.org> # __struct_group_tag()
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20241219135734.2130002-1-aleksander.lobakin@intel.com
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/uapi/linux/stddef.h       | 13 ++++++++++---
 tools/include/uapi/linux/stddef.h | 15 +++++++++++----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h
index 2ec6f35cda32..473ad86706d8 100644
--- a/include/uapi/linux/stddef.h
+++ b/include/uapi/linux/stddef.h
@@ -8,6 +8,13 @@
 #define __always_inline inline
 #endif
 
+/* Not all C++ standards support type declarations inside an anonymous union */
+#ifndef __cplusplus
+#define __struct_group_tag(TAG)		TAG
+#else
+#define __struct_group_tag(TAG)
+#endif
+
 /**
  * __struct_group() - Create a mirrored named and anonyomous struct
  *
@@ -20,13 +27,13 @@
  * and size: one anonymous and one named. The former's members can be used
  * normally without sub-struct naming, and the latter can be used to
  * reason about the start, end, and size of the group of struct members.
- * The named struct can also be explicitly tagged for layer reuse, as well
- * as both having struct attributes appended.
+ * The named struct can also be explicitly tagged for layer reuse (C only),
+ * as well as both having struct attributes appended.
  */
 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
 	union { \
 		struct { MEMBERS } ATTRS; \
-		struct TAG { MEMBERS } ATTRS NAME; \
+		struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
 	} ATTRS
 
 #ifdef __cplusplus
diff --git a/tools/include/uapi/linux/stddef.h b/tools/include/uapi/linux/stddef.h
index bb6ea517efb5..c53cde425406 100644
--- a/tools/include/uapi/linux/stddef.h
+++ b/tools/include/uapi/linux/stddef.h
@@ -8,6 +8,13 @@
 #define __always_inline __inline__
 #endif
 
+/* Not all C++ standards support type declarations inside an anonymous union */
+#ifndef __cplusplus
+#define __struct_group_tag(TAG)		TAG
+#else
+#define __struct_group_tag(TAG)
+#endif
+
 /**
  * __struct_group() - Create a mirrored named and anonyomous struct
  *
@@ -20,14 +27,14 @@
  * and size: one anonymous and one named. The former's members can be used
  * normally without sub-struct naming, and the latter can be used to
  * reason about the start, end, and size of the group of struct members.
- * The named struct can also be explicitly tagged for layer reuse, as well
- * as both having struct attributes appended.
+ * The named struct can also be explicitly tagged for layer reuse (C only),
+ * as well as both having struct attributes appended.
  */
 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
 	union { \
 		struct { MEMBERS } ATTRS; \
-		struct TAG { MEMBERS } ATTRS NAME; \
-	}
+		struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
+	} ATTRS
 
 /**
  * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
-- 
2.39.5




  parent reply	other threads:[~2024-12-30 15:51 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-30 15:42 [PATCH 6.6 00/86] 6.6.69-rc1 review Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 01/86] media: dvb-frontends: dib3000mb: fix uninit-value in dib3000_write_reg Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 02/86] ceph: try to allocate a smaller extent map for sparse read Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 03/86] ceph: fix memory leak in ceph_direct_read_write() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 04/86] ceph: allocate sparse_ext map only for sparse reads Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 05/86] mm/vmstat: fix a W=1 clang compiler warning Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 06/86] tcp_bpf: Charge receive socket buffer in bpf_tcp_ingress() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 07/86] tcp_bpf: Add sk_rmem_alloc related logic for tcp_bpf ingress redirection Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 08/86] bpf: Check negative offsets in __bpf_skb_min_len() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 09/86] nfsd: Revert "nfsd: release svc_expkey/svc_export with rcu_work" Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 10/86] nfsd: restore callback functionality for NFSv4.0 Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 11/86] mtd: diskonchip: Cast an operand to prevent potential overflow Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 12/86] mtd: rawnand: arasan: Fix double assertion of chip-select Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 13/86] mtd: rawnand: arasan: Fix missing de-registration of NAND Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 14/86] phy: qcom-qmp: Fix register name in RX Lane config of SC8280XP Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 15/86] phy: core: Fix an OF node refcount leakage in _of_phy_get() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 16/86] phy: core: Fix an OF node refcount leakage in of_phy_provider_lookup() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 17/86] phy: core: Fix that API devm_phy_put() fails to release the phy Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 18/86] phy: core: Fix that API devm_of_phy_provider_unregister() fails to unregister the phy provider Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 19/86] phy: core: Fix that API devm_phy_destroy() fails to destroy the phy Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 20/86] phy: usb: Toggle the PHY power during init Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 21/86] phy: rockchip: naneng-combphy: fix phy reset Greg Kroah-Hartman
2025-01-29 13:27   ` [REGRESSION] USB 3 and PCIe broken on rk356x due to missing " Jan Čermák
2025-01-29 13:36     ` Greg Kroah-Hartman
2025-01-29 13:50       ` Jan Čermák
2025-01-29 13:55       ` Heiko Stübner
2025-01-29 18:41         ` Vinod Koul
2025-01-29 21:06           ` Heiko Stübner
2024-12-30 15:42 ` [PATCH 6.6 22/86] dmaengine: mv_xor: fix child node refcount handling in early exit Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 23/86] dmaengine: dw: Select only supported masters for ACPI devices Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 24/86] dmaengine: tegra: Return correct DMA status when paused Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 25/86] dmaengine: fsl-edma: implement the cleanup path of fsl_edma3_attach_pd() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 26/86] dmaengine: apple-admac: Avoid accessing registers in probe Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 27/86] dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 28/86] mtd: rawnand: fix double free in atmel_pmecc_create_user() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 29/86] powerpc/pseries/vas: Add close() callback in vas_vm_ops struct Greg Kroah-Hartman
2024-12-30 15:42 ` Greg Kroah-Hartman [this message]
2024-12-30 15:42 ` [PATCH 6.6 31/86] tracing/kprobe: Make trace_kprobes module callback called after jump_label update Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 32/86] watchdog: it87_wdt: add PWRGD enable quirk for Qotom QCML04 Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 33/86] watchdog: mediatek: Add support for MT6735 TOPRGU/WDT Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 34/86] scsi: qla1280: Fix hw revision numbering for ISP1020/1040 Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 35/86] scsi: megaraid_sas: Fix for a potential deadlock Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 36/86] udf: Skip parent dir link count update if corrupted Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 37/86] ALSA: hda/conexant: fix Z60MR100 startup pop issue Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 38/86] ALSA: sh: Use standard helper for buffer accesses Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 39/86] smb: server: Fix building with GCC 15 Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 40/86] regmap: Use correct format specifier for logging range errors Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 41/86] LoongArch: Fix reserving screen info memory for above-4G firmware Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 42/86] LoongArch: BPF: Adjust the parameter of emit_jirl() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 43/86] platform/x86: asus-nb-wmi: Ignore unknown event 0xCF Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 44/86] spi: intel: Add Panther Lake SPI controller support Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 45/86] scsi: mpt3sas: Diag-Reset when Doorbell-In-Use bit is set during driver load time Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 46/86] scsi: storvsc: Do not flag MAINTENANCE_IN return of SRB_STATUS_DATA_OVERRUN as an error Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 47/86] spi: omap2-mcspi: Fix the IS_ERR() bug for devm_clk_get_optional_enabled() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 48/86] drm/dp_mst: Ensure mst_primary pointer is valid in drm_dp_mst_handle_up_req() Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 49/86] virtio-blk: dont keep queue frozen during system suspend Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 50/86] blk-mq: register cpuhp callback after hctx is added to xarray table Greg Kroah-Hartman
2024-12-30 15:42 ` [PATCH 6.6 51/86] blk-mq: move cpuhp callback registering out of q->sysfs_lock Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 52/86] MIPS: Probe toolchain support of -msym32 Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 53/86] MIPS: mipsregs: Set proper ISA level for virt extensions Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 54/86] sched/task_stack: fix object_is_on_stack() for KASAN tagged pointers Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 55/86] ALSA: hda/realtek: fix mute/micmute LEDs dont work for EliteBook X G1i Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 56/86] ALSA: hda/realtek: fix micmute LEDs dont work on HP Laptops Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 57/86] pmdomain: core: Add missing put_device() Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 58/86] drm/amd/amdgpu: allow use kiq to do hdp flush under sriov Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 59/86] drm/amdgpu/hdp4.0: do a posting read when flushing HDP Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 60/86] drm/amdgpu/hdp5.0: " Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 61/86] drm/amdgpu/hdp6.0: " Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 62/86] x86/cpu: Add model number for Intel Clearwater Forest processor Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 63/86] x86/cpu: Add model number for another Intel Arrow Lake mobile processor Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 64/86] x86/cpu/vfm: Add/initialize x86_vfm field to struct cpuinfo_x86 Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 65/86] x86/cpu/vfm: Update arch/x86/include/asm/intel-family.h Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 66/86] x86/cpu/intel: Switch to new Intel CPU model defines Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 67/86] x86/cpu: Add Lunar Lake to list of CPUs with a broken MONITOR implementation Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 68/86] drm/amdkfd: reduce stack size in kfd_topology_add_device() Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 69/86] drm/amdkfd: drop struct kfd_cu_info Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 70/86] drm/amdkfd: Use device based logging for errors Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 71/86] drm/amdkfd: pause autosuspend when creating pdd Greg Kroah-Hartman
2024-12-30 16:04   ` Li, Yunxiang (Teddy)
2025-01-02  9:32     ` Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 72/86] freezer, sched: Report frozen tasks as D instead of R Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 73/86] tracing: Constify string literal data member in struct trace_event_call Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 74/86] tracing: Prevent bad count for tracing_cpumask_write Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 75/86] io_uring/sqpoll: fix sqpoll error handling races Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 76/86] i2c: microchip-core: actually use repeated sends Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 77/86] PCI/MSI: Handle lack of irqdomain gracefully Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 78/86] i2c: imx: add imx7d compatible string for applying erratum ERR007805 Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 79/86] i2c: microchip-core: fix "ghost" detections Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 80/86] power: supply: gpio-charger: Fix set charge current limits Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 81/86] btrfs: avoid monopolizing a core when activating a swap file Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 82/86] btrfs: sysfs: fix direct super block member reads Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 83/86] ALSA: sh: Fix wrong argument order for copy_from_iter() Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 84/86] x86/cpu/intel: Drop stray FAM6 check with new Intel CPU model defines Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 85/86] ALSA: hda/realtek: Fix spelling mistake "Firelfy" -> "Firefly" Greg Kroah-Hartman
2024-12-30 15:43 ` [PATCH 6.6 86/86] block: avoid to reuse `hctx` not removed from cpuhp callback list Greg Kroah-Hartman
2024-12-30 17:51 ` [PATCH 6.6 00/86] 6.6.69-rc1 review Florian Fainelli
2024-12-30 20:58 ` Shuah Khan
2024-12-31  8:12 ` Muhammad Usama Anjum
2024-12-31  9:39 ` Naresh Kamboju
2024-12-31 13:03 ` Harshit Mogalapalli
2024-12-31 22:35 ` [PATCH 6.6] " Hardik Garg
2024-12-31 22:54 ` [PATCH 6.6 00/86] " Ron Economos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241230154212.867663436@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=cferris@google.com \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox