Skip to contentSkip to conversation

lkdtm/bugs: fix build error in lkdtm_UNSET_SMEP

PATCH In review Brendan Higgins 2 participants 2 messages Dec 13, 2019 – Dec 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lkdtm/bugs: fix build error in lkdtm_UNSET_SMEP

When building ARCH=um with CONFIG_UML_X86=y and CONFIG_64BIT=y we get the build errors:

drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_UNSET_SMEP’:
drivers/misc/lkdtm/bugs.c:288:8: error: implicit declaration of function ‘native_read_cr4’ [-Werror=implicit-function-declaration]

  cr4 = native_read_cr4();
        ^~~~~~~~~~~~~~~
drivers/misc/lkdtm/bugs.c:290:13: error: ‘X86_CR4_SMEP’ undeclared (first use in this function); did you mean ‘X86_FEATURE_SMEP’?
  if ((cr4 & X86_CR4_SMEP) != X86_CR4_SMEP) {
             ^~~~~~~~~~~~
             X86_FEATURE_SMEP

drivers/misc/lkdtm/bugs.c:290:13: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/lkdtm/bugs.c:297:2: error: implicit declaration of function ‘native_write_cr4’; did you mean ‘direct_write_cr4’? [-Werror=implicit-function-declaration]
native_write_cr4(cr4);
^~~~~~~~~~~~~~~~
direct_write_cr4

So specify that this block of code should only build when CONFIG_X86_64=y *AND* CONFIG_UML is unset.

---

This patch is part of my larger effort to get allyesconfig closer to working for ARCH=um. For more information about that, checkout the cover letter for a related patchset here:

https://lore.kernel.org/lkml/[email protected]/

---
 drivers/misc/lkdtm/bugs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/lkdtm/bugs.c +1 -1
index a4fdad04809a9..6c1aab177fced 100644
@@ -278,7 +278,7 @@ void lkdtm_STACK_GUARD_PAGE_TRAILING(void)
 
 void lkdtm_UNSET_SMEP(void)
 {
-#ifdef CONFIG_X86_64
+#if IS_ENABLED(CONFIG_X86_64) && !IS_ENABLED(CONFIG_UML)
 #define MOV_CR4_DEPTH	64
 	void (*direct_write_cr4)(unsigned long val);
 	unsigned char *insn;
Signature · 1 line
2.24.1.735.g03f4e72817-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Brendan Higgins

When building ARCH=um with CONFIG_UML_X86=y and CONFIG_64BIT=y we get the build errors:

drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_UNSET_SMEP’:
drivers/misc/lkdtm/bugs.c:288:8: error: implicit declaration of function ‘native_read_cr4’ [-Werror=implicit-function-declaration]

  cr4 = native_read_cr4();
        ^~~~~~~~~~~~~~~
drivers/misc/lkdtm/bugs.c:290:13: error: ‘X86_CR4_SMEP’ undeclared (first use in this function); did you mean ‘X86_FEATURE_SMEP’?
  if ((cr4 & X86_CR4_SMEP) != X86_CR4_SMEP) {
             ^~~~~~~~~~~~
             X86_FEATURE_SMEP

drivers/misc/lkdtm/bugs.c:290:13: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/lkdtm/bugs.c:297:2: error: implicit declaration of function ‘native_write_cr4’; did you mean ‘direct_write_cr4’? [-Werror=implicit-function-declaration]
native_write_cr4(cr4);
^~~~~~~~~~~~~~~~
direct_write_cr4

Quoted 4 lines

So specify that this block of code should only build when CONFIG_X86_64=y *AND* CONFIG_UML is unset.

Thanks for catching this! Is a similar marking needed for the recently added lkdtm_DOUBLE_FAULT() when using UML on 32-bit?

-Kees

Quoted 28 lines

---

This patch is part of my larger effort to get allyesconfig closer to working for ARCH=um. For more information about that, checkout the cover letter for a related patchset here:

https://lore.kernel.org/lkml/[email protected]/

---
 drivers/misc/lkdtm/bugs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/lkdtm/bugs.c +1 -1
index a4fdad04809a9..6c1aab177fced 100644
@@ -278,7 +278,7 @@ void lkdtm_STACK_GUARD_PAGE_TRAILING(void)
 
 void lkdtm_UNSET_SMEP(void)
 {
-#ifdef CONFIG_X86_64
+#if IS_ENABLED(CONFIG_X86_64) && !IS_ENABLED(CONFIG_UML)
 #define MOV_CR4_DEPTH	64
 	void (*direct_write_cr4)(unsigned long val);
 	unsigned char *insn;
Signature · 1 line
2.24.1.735.g03f4e72817-goog
Signature · 6 lines
Kees Cook

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um