From: Sid Nayyar <sidnayyar@google.com>
To: Petr Pavlu <petr.pavlu@suse.com>
Cc: "Nathan Chancellor" <nathan@kernel.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Nicolas Schier" <nicolas.schier@linux.dev>,
"Arnd Bergmann" <arnd@arndb.de>,
linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
"Giuliano Procida" <gprocida@google.com>,
"Matthias Männich" <maennich@google.com>
Subject: Re: [RFC PATCH 00/10] scalable symbol flags with __kflagstab
Date: Fri, 26 Sep 2025 01:11:12 +0100 [thread overview]
Message-ID: <CA+OvW8ZrbdqDGDkt8jXUX3Vg2aLSzVrP-a39Lqvxd1DYOOUg5g@mail.gmail.com> (raw)
In-Reply-To: <2bf54830-ea9c-4962-a7ef-653fbed8f8c0@suse.com>
On Mon, Sep 22, 2025 at 12:41 PM Petr Pavlu <petr.pavlu@suse.com> wrote:
> This is useful information. However, I was specifically interested in
> the impact of having the new flags field present as part of __ksymtab
> (kernel_symbol), compared to keeping it in a separate section. Sorry for
> not being clear.
>
> I ran a small test to get a better understanding of the different sizes.
> I used v6.17-rc6 together with the openSUSE x86_64 config [1], which is
> fairly large. The resulting vmlinux.bin (no debuginfo) had an on-disk
> size of 58 MiB, and included 5937 + 6589 (GPL-only) exported symbols.
>
> The following table summarizes my measurements and calculations
> regarding the sizes of all sections related to exported symbols:
>
> | HAVE_ARCH_PREL32_RELOCATIONS | !HAVE_ARCH_PREL32_RELOCATIONS
> Section | Base [B] | Ext. [B] | Sep. [B] | Base [B] | Ext. [B] | Sep. [B]
> ----------------------------------------------------------------------------------------
> __ksymtab | 71244 | 200416 | 150312 | 142488 | 400832 | 300624
> __ksymtab_gpl | 79068 | NA | NA | 158136 | NA | NA
> __kcrctab | 23748 | 50104 | 50104 | 23748 | 50104 | 50104
> __kcrctab_gpl | 26356 | NA | NA | 26356 | NA | NA
> __ksymtab_strings | 253628 | 253628 | 253628 | 253628 | 253628 | 253628
> __kflagstab | NA | NA | 12526 | NA | NA | 12526
> ----------------------------------------------------------------------------------------
> Total | 454044 | 504148 | 466570 | 604356 | 704564 | 616882
> Increase to base [%] | NA | 11.0 | 2.8 | NA | 16.6 | 2.1
>
> The column "HAVE_ARCH_PREL32_RELOCATIONS -> Base" contains the numbers
> that I measured. The rest of the values are calculated. The "Ext."
> column represents the variant of extending __ksymtab, and the "Sep."
> column represents the variant of having a separate __kflagstab. With
> HAVE_ARCH_PREL32_RELOCATIONS, each kernel_symbol is 12 B in size and is
> extended to 16 B. With !HAVE_ARCH_PREL32_RELOCATIONS, it is 24 B,
> extended to 32 B. Note that this does not include the metadata needed to
> relocate __ksymtab*, which is freed after the initial processing.
>
> The base export data in this case totals 0.43 MiB. About 50% is used for
> storing the names of exported symbols.
>
> Adding __kflagstab as a separate section has a negligible impact, as
> expected. When extending __ksymtab (kernel_symbol) instead, the worst
> case with !HAVE_ARCH_PREL32_RELOCATIONS increases the export data size
> by 16.6%.
>
> Based on the above, I think introducing __kflagstab makes senses, as the
> added complexity is minimal, although I feel we could probably also get
> away with extending kernel_symbol.
This investigation is very informative, thank you for sharing your
findings. I am in agreement with your conclusions.
> This seems to answer why the in-tree flag is not sufficient for you.
> However, I also suggested an alternative that the symbol protection
> could be determined by whether the module is signed by a key from the
> .builtin_trusted_keys keyring, as opposed to being signed by another key
> reachable from the .secondary_trusted_keys keyring or being completely
> unsigned.
>
> Distributions can require that external modules be signed and allow
> additional keys to be added as Machine Owner Keys, which can be made
> reachable from .secondary_trusted_keys. Nonetheless, such distributions
> might be still interested in limiting the number of symbols that such
> external modules can use.
>
> I think this option is worth considering, as it could potentially make
> this symbol protection useful for other distributions as well.
This sounds like a great solution to enhance trust and security,
apologies for missing this in the previous email. I will explore this
approach, but I would like to do it in a separate series.
> I'm personally ok with adding the kflagstab support. I think it
> introduces minimal complexity and, as you point out, simplifies certain
> aspects. Additionally, if we add it, I believe that adding the proposed
> symbol protection is simple enough to be included as well, at least from
> my perspective.
Since we are in agreement, I would like to seek code review for this
series. The code is ready for review from my side, but if you prefer I
can send out a non-RFC patch series for code review.
--
Thanks,
Siddharth Nayyar
prev parent reply other threads:[~2025-09-26 0:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 10:54 [RFC PATCH 00/10] scalable symbol flags with __kflagstab Siddharth Nayyar
2025-08-29 10:54 ` [PATCH 01/10] define kernel symbol flags Siddharth Nayyar
2025-08-29 10:54 ` [PATCH 02/10] linker: add kflagstab section to vmlinux and modules Siddharth Nayyar
2025-08-29 10:54 ` [PATCH 03/10] modpost: create entries for kflagstab Siddharth Nayyar
2025-08-29 10:54 ` [PATCH 04/10] module loader: use kflagstab instead of *_gpl sections Siddharth Nayyar
2025-10-08 13:19 ` Petr Pavlu
2025-08-29 10:54 ` [PATCH 05/10] modpost: put all exported symbols in ksymtab section Siddharth Nayyar
2025-08-29 10:54 ` [PATCH 06/10] module loader: remove references of *_gpl sections Siddharth Nayyar
2025-10-08 13:22 ` Petr Pavlu
2025-08-29 10:54 ` [PATCH 07/10] linker: remove *_gpl sections from vmlinux and modules Siddharth Nayyar
2025-08-29 10:54 ` [PATCH 08/10] remove references to *_gpl sections in documentation Siddharth Nayyar
2025-10-08 13:24 ` Petr Pavlu
2025-08-29 10:54 ` [PATCH 09/10] modpost: add symbol import protection flag to kflagstab Siddharth Nayyar
2025-10-08 13:35 ` Petr Pavlu
2025-08-29 10:54 ` [PATCH 10/10] module loader: enforce symbol import protection Siddharth Nayyar
2025-10-08 15:35 ` Petr Pavlu
2025-09-01 12:27 ` [RFC PATCH 00/10] scalable symbol flags with __kflagstab Petr Pavlu
2025-09-03 23:28 ` Sid Nayyar
2025-09-08 10:09 ` Petr Pavlu
2025-09-15 15:53 ` Sid Nayyar
2025-09-22 11:41 ` Petr Pavlu
2025-09-26 0:11 ` Sid Nayyar [this message]
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=CA+OvW8ZrbdqDGDkt8jXUX3Vg2aLSzVrP-a39Lqvxd1DYOOUg5g@mail.gmail.com \
--to=sidnayyar@google.com \
--cc=arnd@arndb.de \
--cc=gprocida@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=maennich@google.com \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas.schier@linux.dev \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.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;
as well as URLs for NNTP newsgroup(s).