[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c49d316d-ce8f-43d4-8116-80c760e38a6b@intel.com>
Date: Tue, 17 Dec 2024 17:04:41 +0100
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
CC: Kees Cook <kees@...nel.org>, Jakub Kicinski <kuba@...nel.org>,
<cferris@...gle.com>, Jamal Hadi Salim <jhs@...atatu.com>, Cong Wang
<xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>,
<netdev@...r.kernel.org>, "Gustavo A. R. Silva" <gustavoars@...nel.org>,
<linux-kernel@...r.kernel.org>, <linux-hardening@...r.kernel.org>
Subject: Re: [PATCH] UAPI: net/sched: Open-code __struct_group() in flex
struct tc_u32_sel
From: Gustavo A. R. Silva <gustavo@...eddedor.com>
Date: Tue, 17 Dec 2024 09:58:28 -0600
>
>
> On 17/12/24 08:55, Alexander Lobakin wrote:
>> From: Kees Cook <kees@...nel.org>
>> Date: Mon, 16 Dec 2024 18:59:55 -0800
>>
>>> This switches to using a manually constructed form of struct tagging
>>> to avoid issues with C++ being unable to parse tagged structs within
>>> anonymous unions, even under 'extern "C"':
>>>
>>> ../linux/include/uapi/linux/pkt_cls.h:25124: error: ‘struct
>>> tc_u32_sel::<unnamed union>::tc_u32_sel_hdr,’ invalid; an anonymous
>>> union may only have public non-static data members [-fpermissive]
>>
>> I worked around that like this in the past: [0]
>> As I'm not sure it would be fine to fix every such occurrence manually
>> by open-coding.
>> What do you think?
>
> The thing is that, in this particular case, we need a struct tag to change
> the type of an object in another struct. See:
But the fix I mentioned still allows you to specify a tag in C code...
cxgb4 is for sure not C++.
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h b/
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
> index 9050568a034c..64663112cad8 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
> @@ -242,7 +242,7 @@ struct cxgb4_next_header {
> * field's value to jump to next header such as IHL field
> * in IPv4 header.
> */
> - struct tc_u32_sel sel;
> + struct tc_u32_sel_hdr sel;
> struct tc_u32_key key;
> /* location of jump to make */
> const struct cxgb4_match_field *jump;;
>
> You can also take a look at the original series:
>
> https://lore.kernel.org/linux-hardening/
> cover.1723586870.git.gustavoars@...nel.org/
>
> Thanks
> --
> Gustavo
Thanks,
Olek
Powered by blists - more mailing lists