From: Jessica Yu <jeyu@kernel.org>
To: Frank van der Linden <fllinden@amazon.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] module: harden ELF info handling
Date: Mon, 18 Jan 2021 16:18:27 +0100 [thread overview]
Message-ID: <20210118151827.GA22792@linux-8ccs> (raw)
In-Reply-To: <20210114222146.25762-1-fllinden@amazon.com>
+++ Frank van der Linden [14/01/21 22:21 +0000]:
>5fdc7db644 ("module: setup load info before module_sig_check()")
>moved the ELF setup, so that it was done before the signature
>check. This made the module name available to signature error
>messages.
>
>However, the checks for ELF correctness in setup_load_info
>are not sufficient to prevent bad memory references due to
>corrupted offset fields, indices, etc.
>
>So, there's a regression in behavior here: a corrupt and unsigned
>(or badly signed) module, which might previously have been rejected
>immediately, can now cause an oops/crash.
>
>Harden ELF handling for module loading by doing the following:
>
>- Move the signature check back up so that it comes before ELF
> initialization. It's best to do the signature check to see
> if we can trust the module, before using the ELF structures
> inside it. This also makes checks against info->len
> more accurate again, as this field will be reduced by the
> length of the signature in mod_check_sig().
>
> The module name is now once again not available for error
> messages during the signature check, but that seems like
> a fair tradeoff.
>
>- Check if sections have offset / size fields that at least don't
> exceed the length of the module.
>
>- Check if sections have section name offsets that don't fall
> outside the section name table.
>
>- Add a few other sanity checks against invalid section indices,
> etc.
>
>This is not an exhaustive consistency check, but the idea is to
>at least get through the signature and blacklist checks without
>crashing because of corrupted ELF info, and to error out gracefully
>for most issues that would have caused problems later on.
>
>Fixes: 5fdc7db644 ("module: setup load info before module_sig_check()")
>Signed-off-by: Frank van der Linden <fllinden@amazon.com>
Queued on modules-next.
Thanks Frank!
Jessica
prev parent reply other threads:[~2021-01-18 15:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 22:21 [PATCH v3] module: harden ELF info handling Frank van der Linden
2021-01-18 15:18 ` Jessica Yu [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=20210118151827.GA22792@linux-8ccs \
--to=jeyu@kernel.org \
--cc=fllinden@amazon.com \
--cc=linux-kernel@vger.kernel.org \
/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.