Re: [PATCH v2 2/5] modules: Refactor + kdoc elf_validity_cached_copy

Greg KH
2023-11-18T11:45:46Z

On Sat, Nov 18, 2023 at 02:54:43AM +0000, Matthew Maurer wrote:
> Functionality is almost identical, just structured for better
> documentation and readability. Changes:
>
> * Section names are checked for *all* non-SHT_NULL sections, not just
> SHF_ALLOC sections. We have code that accesses section names of
> non-SHF_ALLOC sections (see find_any_sec for example)
> * The section name check occurs *before* strcmping on section names.
> Previously, it was possible to use an out-of-bounds offset to strcmp
> against ".modinfo" or ".gnu.linkonce.this_module"
> * strtab is checked for NUL lead+termination and nonzero size
> * The symbol table is swept to ensure offsets are inbounds of strtab
>
> While some of these oversights would normally be worrying, all of the
> potentially unverified accesses occur after signature check, and only in
> response to a user who can load a kernel module.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>
> ---
> kernel/module/internal.h | 7 +-
> kernel/module/main.c | 585 +++++++++++++++++++++++++++++----------
> 2 files changed, 444 insertions(+), 148 deletions(-)

Again, this needs to be broken into much smaller pieces before we can
even review it. Would you want to review this?

thanks,

greg "think of the reviewers" k-h