]> www.infradead.org Git - users/hch/misc.git/commit
module: Factor out elf_validity_cache_secstrings
authorMatthew Maurer <mmaurer@google.com>
Tue, 15 Oct 2024 23:16:38 +0000 (23:16 +0000)
committerLuis Chamberlain <mcgrof@kernel.org>
Sat, 19 Oct 2024 21:35:07 +0000 (14:35 -0700)
commit3c5700aeabd87e81d9153a7666b28d0e405c6c88
treeb4f7ec59dbccd58bc0ac9d238f186b72e69b7253
parentc92aab819d56d51631f0484ed7af11d9d8ff4cb0
module: Factor out elf_validity_cache_secstrings

Factor out the validation of section names.

There are two behavioral changes:

1. Previously, we did not validate non-SHF_ALLOC sections.
   This may have once been safe, as find_sec skips non-SHF_ALLOC
   sections, but find_any_sec, which will be used to load BTF if that is
   enabled, ignores the SHF_ALLOC flag. Since there's no need to support
   invalid section names, validate all of them, not just SHF_ALLOC
   sections.
2. Section names were validated *after* accessing them for the purposes
   of detecting ".modinfo" and ".gnu.linkonce.this_module". They are now
   checked prior to the access, which could avoid bad accesses with
   malformed modules.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
kernel/module/main.c