From: David Laight <david.laight.linux@gmail.com>
To: Jack Wallner <jackwallner@gmail.com>
Cc: Kees Cook <kees@kernel.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@kernel.org>,
Vincenzo Frascino <vincenzo.frascino@arm.com>
Subject: Re: [PATCH 7/8] vdso/align: Preserve object size through PTR_ALIGN()
Date: Mon, 30 Nov 2026 10:46:05 +0000 [thread overview]
Message-ID: <20261130104605.52646f5e@pumpkin> (raw)
In-Reply-To: <CAPtfcKhoDEWA=xXQEQEkPJY3Fo-bfy6La0TD8NC9Rhs4k3ZNtQ@mail.gmail.com>
On Sun, 29 Nov 2026 12:47:41 -0800
Jack Wallner <jackwallner@gmail.com> wrote:
> Hi David,
>
> On Sun, 29 Nov 2026 17:38:16 +0000 David Laight wrote:
> > scripts/bloat-o-meter will tell you exactly where the changes are.
> > It might be that the code is actually larger in a few places.
>
> You're right, it is. I rebuilt every C file that calls PTR_ALIGN() for
> the seven compiler and architecture pairs in the changelog (allmodconfig
> with KASAN, UBSAN and KCOV off), once on the base tree and once with the
> series applied, and compared each object. Function text, leaving out the
> new test:
>
> x86-64 GCC +1394 bytes (+0.07%)
> i386 GCC +980 bytes (+0.05%)
> x86-64 Clang +758 bytes (+0.04%)
> arm64 Clang +536 bytes (+0.02%)
> powerpc Clang +1524 bytes (+0.06%)
> arm Clang +7860 bytes (+0.38%)
> riscv Clang +7496 bytes (+0.39%)
>
> Every architecture gets 12 to 18 new __fortify_panic() call sites (153
> to 166 on x86-64 GCC). Those are the checks the patch is meant to
> enable, and on x86, arm64 and powerpc the functions that gained one
> account for most of the growth; ovpn_aead_decrypt() gains two, for
> example. The two largest growths on x86-64 GCC have no new check,
> though: ath12k_dp_reoq_lut_setup() grows by 416 bytes and ismt_access()
> by 256.
>
> On 32-bit arm and riscv the checks are a small part of it. There the
> growth is spread over hundreds of functions (834 grow on arm, 351 on
> riscv), and on arm 7360 of the 7860 bytes are in functions that gained
> no check; gf128mul_lle() is the largest, at 184 bytes. So the changelog
> is wrong to put the growth down to the object size. I don't know the
> cause yet and will find out before v2.
In a quick check (x - (x & 3)) seems to get compiled as (x & ~3).
That might be enough to keep builtin_dynamic_object_size still
returning a value while stopping the bloat.
Although I'd have thought that the compiler could only track the
size when it already knows the pointer in aligned.
>
> > How did that happen?
> > Why isn't it just ((x) & ~((a) - 1))
>
> It is older than this series. ed067d4a859f ("linux/kernel.h: Add
> ALIGN_DOWN macro", 2017) replaced three local versions, the metag one
> being the mask form, and kept the udl form, ALIGN(x - (a - 1), a).
I'd looked them up as well.
And traced back where the originals had come from.
> The mask form would need a cast to typeof(x), or an unsigned 32-bit a
> clears the top half of a 64-bit x:
>
> ((x) & ~((typeof(x))(a) - 1))
>
> I'd rather keep that out of this series, but I can send it as a
> separate patch if you think it is worth doing.
It is definitely unrelated.
> > Too long.
>
> Cut down to:
>
> /*
> * Add the padding to @p instead of casting an integer back to a pointer,
> * so the compiler still knows the size of the object @p points into.
> * Use ALIGN() for integers.
> */
Still long, maybe just:
/* Add padding so the the compiler still knows the the size of @p */
David
>
> > Doesn't belong here at all.
>
> Dropped. That reasoning stays in the changelog only.
>
> Both will be in v2.
>
> Thanks,
> Jack
next prev parent reply other threads:[~2026-11-30 10:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 8:56 [PATCH 0/8] " Jack Wallner
2026-11-29 8:56 ` [PATCH 1/8] crypto: gcm, ccm - Derive the rfc4106/rfc4309 IV from the request context Jack Wallner
2026-11-29 8:56 ` [PATCH 2/8] crypto: nitrox, octeontx, octeontx2 - Use ALIGN() on DMA addresses Jack Wallner
2026-11-29 8:56 ` [PATCH 3/8] misc: pci_endpoint_test: " Jack Wallner
2026-11-29 8:56 ` [PATCH 4/8] be2net: Use ALIGN() on a DMA address Jack Wallner
2026-11-29 8:56 ` [PATCH 5/8] octeontx2-pf: " Jack Wallner
2026-11-30 4:14 ` Ratheesh Kannoth
2026-11-29 8:56 ` [PATCH 6/8] scsi: be2iscsi: " Jack Wallner
2026-11-29 8:56 ` [PATCH 7/8] vdso/align: Preserve object size through PTR_ALIGN() Jack Wallner
2026-11-29 11:03 ` Alejandro Colomar
2026-11-29 17:32 ` Jack Wallner
2026-11-29 17:38 ` David Laight
2026-11-29 20:47 ` Jack Wallner
2026-11-30 10:46 ` David Laight [this message]
2026-11-29 8:56 ` [PATCH 8/8] kunit/fortify: Add PTR_ALIGN() object size test Jack Wallner
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=20261130104605.52646f5e@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=jackwallner@gmail.com \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=tglx@kernel.org \
--cc=vincenzo.frascino@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®