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: <1b373b08-988d-b870-d363-814f8083157c@embeddedor.com>
Date:   Wed, 16 Nov 2022 19:20:51 -0600
From:   "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     Kees Cook <keescook@...omium.org>,
        David Ahern <dsahern@...nel.org>, davem@...emloft.net,
        netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH net-next v2] netlink: split up copies in the ack
 construction



On 11/16/22 19:05, Jakub Kicinski wrote:
> On Wed, 16 Nov 2022 18:55:36 -0600 Gustavo A. R. Silva wrote:
>>> @@ -56,7 +55,6 @@ struct nlmsghdr {
>>>    	__u16		nlmsg_flags;
>>>    	__u32		nlmsg_seq;
>>>    	__u32		nlmsg_pid;
>>> -	__u8		nlmsg_data[];
>>>    };
>>
>> This seems to be a sensible change. In general, it's not a good idea
>> to have variable length objects (flex-array members) in structures used
>> as headers, and that we know will ultimately be followed by more objects
>> when embedded inside other structures.
> 
> Meaning we should go back to zero-length arrays instead?

No.
> Is there something in the standard that makes flexible array
> at the end of an embedded struct a problem?

I haven't seen any problems ss long as the flex-array appears last:

struct foo {
	... members
	struct boo {
		... members
		char flex[];
	};
};

struct complex {
	... members
	struct foo embedded;
};

However, the GCC docs[1] mention this:

"A structure containing a flexible array member [..] may not be a
member of a structure [..] (However, these uses are permitted by GCC
as extensions.)"

And in this case it seems that's the reason why GCC doesn't complain?

--
Gustavo

[1] https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Zero-Length.html#Zero-Length

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ