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: <20220221100615.GK23216@worktop.programming.kicks-ass.net>
Date:   Mon, 21 Feb 2022 11:06:15 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Kees Cook <keescook@...omium.org>
Cc:     x86@...nel.org, joao@...rdrivepizza.com, hjl.tools@...il.com,
        jpoimboe@...hat.com, andrew.cooper3@...rix.com,
        linux-kernel@...r.kernel.org, ndesaulniers@...gle.com,
        samitolvanen@...gle.com, mark.rutland@....com,
        alyssa.milburn@...el.com
Subject: Re: [PATCH 15/29] x86: Disable IBT around firmware


Could you trim replies so that I can actually find what you write?

On Mon, Feb 21, 2022 at 12:27:20AM -0800, Kees Cook wrote:

> >+#ifdef CONFIG_X86_IBT
> >+
> >+u64 ibt_save(void)
> >+{
> >+	u64 msr = 0;
> >+
> >+	if (cpu_feature_enabled(X86_FEATURE_IBT)) {
> >+		rdmsrl(MSR_IA32_S_CET, msr);
> >+		wrmsrl(MSR_IA32_S_CET, msr & ~CET_ENDBR_EN);
> >+	}
> >+
> >+	return msr;
> >+}
> >+
> >+void ibt_restore(u64 save)
> 
> Please make these both __always_inline so there no risk of them ever gaining ENDBRs and being used by ROP to disable IBT...

Either that or mark them __noendbr. The below seems to work.

Do we have a preference?


--- a/arch/x86/include/asm/ibt.h
+++ b/arch/x86/include/asm/ibt.h
@@ -48,8 +48,8 @@ static inline bool is_endbr(const void *
 	return val == gen_endbr64();
 }
 
-extern u64 ibt_save(void);
-extern void ibt_restore(u64 save);
+extern __noendbr u64 ibt_save(void);
+extern __noendbr void ibt_restore(u64 save);
 
 #else /* __ASSEMBLY__ */
 
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -596,7 +596,7 @@ __setup("nopku", setup_disable_pku);
 
 #ifdef CONFIG_X86_IBT
 
-u64 ibt_save(void)
+__noendbr u64 ibt_save(void)
 {
 	u64 msr = 0;
 
@@ -608,7 +608,7 @@ u64 ibt_save(void)
 	return msr;
 }
 
-void ibt_restore(u64 save)
+__noendbr void ibt_restore(u64 save)
 {
 	u64 msr;
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ