current_stack_pointer missing on ARM and likely other arches

Discuss and suggest new grsecurity features

current_stack_pointer missing on ARM and likely other arches

Postby N8Fear » Sun Jun 08, 2014 4:22 am

Hi,
I'm using Gentoo's hardened-sources-3.14.5-r2 which contains the grsec-patch with the following version string: 201406051310 (seems to be the latest).
Building fails with the following error:
Code: Select all
fs/exec.c:2056:15: error: ‘current_stack_pointer’ undeclared (first use in this function)

(It's longer but that is the essence of it).
After digging through the sources it seems like that definition is missing for arm and several other arches (mips for example).

The following patch fixes the issue for arm:
Code: Select all
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index 8bb9ae1..b0aa2c8 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -185,5 +185,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
  */
 #define _TIF_WORK_MASK      (_TIF_NEED_RESCHED | _TIF_SIGPENDING | _TIF_NOTIFY_RESUME)
 
+
+#define current_stack_pointer ({      \
+   unsigned long sp;         \
+   asm("mov sp,%0" : "=g" (sp));   \
+   sp;               \
+})
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_ARM_THREAD_INFO_H */


Since I didn't try other arches I won't include "should work"-quality patches but my guess is that some of them need similar changes.

As of 3.14.6 this issue is resolved.
N8Fear
 
Posts: 37
Joined: Thu Jan 17, 2013 5:01 am

Return to grsecurity development

cron