[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <96ff90ff-35ed-44a9-bd3e-cf8070a8550b@embeddedor.com>
Date: Fri, 12 Sep 2025 13:00:38 +0200
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Uwe Kleine-König <u.kleine-koenig@...libre.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>, Kees Cook <kees@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] stddef: Stop using FAM parameter of
TRAILING_OVERLAP()
On 9/12/25 12:28, Uwe Kleine-König wrote:
> According to my understanding of flexible array members and the c99 docs
> ("In most situations, the flexible array member is ignored. In
> particular, the size of the structure is as if the flexible array member
> were omitted except that it may have more trailing padding than the
> omission would imply.") sizeof(TYPE) yields the same value as
> offsetof(TYPE, FAM). To make FAM unused rename the padding struct member
No, as I commented here[1]:
"Flexible structures (structs that contain a FAM) may have trailing padding.
Under that scenario sizeof(TYPE) causes the overlay between FAM and MEMBERS
to be misaligned.
On the other hand, offsetof(TYPE, FAM) precisely positions the trailing
MEMBERS where the FAM begins, which is correct and safe."
sizeof(TYPE) does not always equal to offsetof(TYPE, FAM).
See this:
https://lore.kernel.org/linux-hardening/aLiYrQGdGmaDTtLF@kspp/
Thanks
-Gustavo
[1] https://lore.kernel.org/linux-hardening/4b9eea66-f004-4b5f-bf48-4c32205cc8ee@embeddedor.com/
Powered by blists - more mailing lists