lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <42179df523b4ab1d9a804f948bd6b0ab6dc69721.camel@linux.ibm.com>
Date:   Fri, 14 Jul 2023 11:02:56 -0400
From:   Mimi Zohar <zohar@...ux.ibm.com>
To:     Coiby Xu <coxu@...hat.com>, Paul Moore <paul@...l-moore.com>
Cc:     linux-integrity@...r.kernel.org,
        linux-security-module <linux-security-module@...r.kernel.org>,
        Eric Biederman <ebiederm@...ssion.com>,
        "open list:KEXEC" <kexec@...ts.infradead.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kexec_file: ima: allow loading a kernel with its IMA
 signature verified

[CC'ing Paul Moore]

On Fri, 2023-07-14 at 09:46 +0800, Coiby Xu wrote:
> On Wed, Jul 12, 2023 at 02:31:43PM -0400, Mimi Zohar wrote:
> >[Cc'ing the LSM mailing list.]
> >
> >On Tue, 2023-07-11 at 11:16 +0800, Coiby Xu wrote:
> >> When IMA has verified the signature of the kernel image, kexec'ing this
> >> kernel should be allowed.
> >>
> >> Fixes: af16df54b89d ("ima: force signature verification when CONFIG_KEXEC_SIG is configured")
> >> Signed-off-by: Coiby Xu <coxu@...hat.com>
> >
> >The original commit  29d3c1c8dfe7 ("kexec: Allow kexec_file() with
> >appropriate IMA policy when locked down") was not in lieu of the PE-
> >COFF signature, but allowed using the IMA signature on other
> >architectures.
> >
> >Currently on systems with both PE-COFF and IMA signatures, both
> >signatures are verified, assuming the file is in the IMA policy.  If
> >either signature verification fails, the kexec fails.
> >
> >With this patch, only the IMA signature would be verified.
> 
> Thanks for correcting me! I thought it's already a consensus that we could use
> either signature to verify a kernel image because that's what the code of
> commit 29d3c1c8dfe7 has done and the code comment seems to confirm it.  But if
> we just read the commit message, it indeed didn't give an answer on whether x86
> and ARM are only allowed to use PE-COFF signature.

I'm not aware of any consensus one way or the other.  Commit
29d3c1c8dfe7 continued to fail the kexec on failure, when
CONFIG_KEXEC_SIG_FORCE was enabled.

As there isn't a lockdown maintainer, Paul are you ok with this change?

> 
> >
> >> ---
> >>  kernel/kexec_file.c | 14 +++++++++-----
> >>  1 file changed, 9 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> >> index 881ba0d1714c..96fce001fbc0 100644
> >> --- a/kernel/kexec_file.c
> >> +++ b/kernel/kexec_file.c
> >> @@ -162,6 +162,13 @@ kimage_validate_signature(struct kimage *image)
> >>  	ret = kexec_image_verify_sig(image, image->kernel_buf,
> >>  				     image->kernel_buf_len);
> >>  	if (ret) {
> >> +		/*
> >> +		 * If the kernel image already has its IMA signature verified, permit it.
> >> +		 */
> >> +		if (ima_appraise_signature(READING_KEXEC_IMAGE)) {
> >> +			pr_notice("The kernel image already has its IMA signature verified.\n");
> >> +			return 0;
> >> +		}
> >>
> >>  		if (sig_enforce) {
> >>  			pr_notice("Enforced kernel signature verification failed (%d).\n", ret);
> >> @@ -169,12 +176,9 @@ kimage_validate_signature(struct kimage *image)
> >>  		}
> >>
> >>  		/*
> >> -		 * If IMA is guaranteed to appraise a signature on the kexec
> >> -		 * image, permit it even if the kernel is otherwise locked
> >> -		 * down.
> >> +		 * When both IMA and KEXEC_SIG fail in lockdown mode, reject it.
> >>  		 */
> >> -		if (!ima_appraise_signature(READING_KEXEC_IMAGE) &&
> >> -		    security_locked_down(LOCKDOWN_KEXEC))
> >> +		if (security_locked_down(LOCKDOWN_KEXEC))
> >>  			return -EPERM;
> >>
> >>  		pr_debug("kernel signature verification failed (%d).\n", ret);
> >
> >
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ