From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Kees Cook" <kees@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] stddef: Stop using FAM parameter of TRAILING_OVERLAP()
Date: Fri, 12 Sep 2025 13:00:38 +0200 [thread overview]
Message-ID: <96ff90ff-35ed-44a9-bd3e-cf8070a8550b@embeddedor.com> (raw)
In-Reply-To: <0c66d2f3dc875664bf0eba7707044e48bb029dc6.1757672423.git.u.kleine-koenig@baylibre.com>
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/
next prev parent reply other threads:[~2025-09-12 11:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 10:28 [PATCH 0/2] stddef: Simplify TRAILING_OVERLAP() and improve docs Uwe Kleine-König
2025-09-12 10:28 ` [PATCH 1/2] stddef: Add a comment about why TRAILING_OVERLAP() exists Uwe Kleine-König
2025-09-12 10:28 ` [PATCH 2/2] stddef: Stop using FAM parameter of TRAILING_OVERLAP() Uwe Kleine-König
2025-09-12 11:00 ` Gustavo A. R. Silva [this message]
2025-09-12 10:51 ` [PATCH 0/2] stddef: Simplify TRAILING_OVERLAP() and improve docs Gustavo A. R. Silva
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=96ff90ff-35ed-44a9-bd3e-cf8070a8550b@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.