* [PATCH v3 0/3] fix function type mismatches in syscall wrappers
@ 2019-05-24 22:11 ` Sami Tolvanen
0 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Kees Cook, Nick Desaulniers, linux-arm-kernel, linux-kernel,
Sami Tolvanen
These patches fix type mismatches in arm64 syscall wrapper
definitions, which trip indirect call checks with Control-Flow
Integrity.
Changes in v3:
- instead of SYSCALL_DEFINE0, just define __arm64_sys_ni_syscall
with the correct type to avoid unnecessary error injection
Changes in v2:
- more informative commit message for the syscall_fn_t change
- added a patch for fixing sys_ni_syscall
Sami Tolvanen (3):
arm64: fix syscall_fn_t type
arm64: use the correct function type in SYSCALL_DEFINE0
arm64: use the correct function type for __arm64_sys_ni_syscall
arch/arm64/include/asm/syscall.h | 2 +-
arch/arm64/include/asm/syscall_wrapper.h | 18 +++++++++---------
arch/arm64/kernel/sys.c | 14 +++++++++-----
arch/arm64/kernel/sys32.c | 7 ++-----
4 files changed, 21 insertions(+), 20 deletions(-)
--
2.22.0.rc1.257.g3120a18244-goog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 0/3] fix function type mismatches in syscall wrappers
@ 2019-05-24 22:11 ` Sami Tolvanen
0 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Sami Tolvanen, Nick Desaulniers, Kees Cook, linux-arm-kernel,
linux-kernel
These patches fix type mismatches in arm64 syscall wrapper
definitions, which trip indirect call checks with Control-Flow
Integrity.
Changes in v3:
- instead of SYSCALL_DEFINE0, just define __arm64_sys_ni_syscall
with the correct type to avoid unnecessary error injection
Changes in v2:
- more informative commit message for the syscall_fn_t change
- added a patch for fixing sys_ni_syscall
Sami Tolvanen (3):
arm64: fix syscall_fn_t type
arm64: use the correct function type in SYSCALL_DEFINE0
arm64: use the correct function type for __arm64_sys_ni_syscall
arch/arm64/include/asm/syscall.h | 2 +-
arch/arm64/include/asm/syscall_wrapper.h | 18 +++++++++---------
arch/arm64/kernel/sys.c | 14 +++++++++-----
arch/arm64/kernel/sys32.c | 7 ++-----
4 files changed, 21 insertions(+), 20 deletions(-)
--
2.22.0.rc1.257.g3120a18244-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/3] arm64: fix syscall_fn_t type
2019-05-24 22:11 ` Sami Tolvanen
@ 2019-05-24 22:11 ` Sami Tolvanen
-1 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Kees Cook, Nick Desaulniers, linux-arm-kernel, linux-kernel,
Sami Tolvanen
Syscall wrappers in <asm/syscall_wrapper.h> use const struct pt_regs *
as the argument type. Use const in syscall_fn_t as well to fix indirect
call type mismatches with Control-Flow Integrity checking.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
---
arch/arm64/include/asm/syscall.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index a65167f5cded8..e8bcb9ecede9b 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -20,7 +20,7 @@
#include <linux/compat.h>
#include <linux/err.h>
-typedef long (*syscall_fn_t)(struct pt_regs *regs);
+typedef long (*syscall_fn_t)(const struct pt_regs *regs);
extern const syscall_fn_t sys_call_table[];
--
2.22.0.rc1.257.g3120a18244-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 1/3] arm64: fix syscall_fn_t type
@ 2019-05-24 22:11 ` Sami Tolvanen
0 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Sami Tolvanen, Nick Desaulniers, Kees Cook, linux-arm-kernel,
linux-kernel
Syscall wrappers in <asm/syscall_wrapper.h> use const struct pt_regs *
as the argument type. Use const in syscall_fn_t as well to fix indirect
call type mismatches with Control-Flow Integrity checking.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
---
arch/arm64/include/asm/syscall.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index a65167f5cded8..e8bcb9ecede9b 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -20,7 +20,7 @@
#include <linux/compat.h>
#include <linux/err.h>
-typedef long (*syscall_fn_t)(struct pt_regs *regs);
+typedef long (*syscall_fn_t)(const struct pt_regs *regs);
extern const syscall_fn_t sys_call_table[];
--
2.22.0.rc1.257.g3120a18244-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/3] arm64: use the correct function type in SYSCALL_DEFINE0
2019-05-24 22:11 ` Sami Tolvanen
@ 2019-05-24 22:11 ` Sami Tolvanen
-1 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Kees Cook, Nick Desaulniers, linux-arm-kernel, linux-kernel,
Sami Tolvanen
Although a syscall defined using SYSCALL_DEFINE0 doesn't accept
parameters, use the correct function type to avoid indirect call
type mismatches with Control-Flow Integrity checking.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
arch/arm64/include/asm/syscall_wrapper.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h
index a4477e515b798..507d0ee6bc690 100644
--- a/arch/arm64/include/asm/syscall_wrapper.h
+++ b/arch/arm64/include/asm/syscall_wrapper.h
@@ -30,10 +30,10 @@
} \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
-#define COMPAT_SYSCALL_DEFINE0(sname) \
- asmlinkage long __arm64_compat_sys_##sname(void); \
- ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
- asmlinkage long __arm64_compat_sys_##sname(void)
+#define COMPAT_SYSCALL_DEFINE0(sname) \
+ asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \
+ ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
+ asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused)
#define COND_SYSCALL_COMPAT(name) \
cond_syscall(__arm64_compat_sys_##name);
@@ -62,11 +62,11 @@
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#ifndef SYSCALL_DEFINE0
-#define SYSCALL_DEFINE0(sname) \
- SYSCALL_METADATA(_##sname, 0); \
- asmlinkage long __arm64_sys_##sname(void); \
- ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
- asmlinkage long __arm64_sys_##sname(void)
+#define SYSCALL_DEFINE0(sname) \
+ SYSCALL_METADATA(_##sname, 0); \
+ asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \
+ ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
+ asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused)
#endif
#ifndef COND_SYSCALL
--
2.22.0.rc1.257.g3120a18244-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/3] arm64: use the correct function type in SYSCALL_DEFINE0
@ 2019-05-24 22:11 ` Sami Tolvanen
0 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Sami Tolvanen, Nick Desaulniers, Kees Cook, linux-arm-kernel,
linux-kernel
Although a syscall defined using SYSCALL_DEFINE0 doesn't accept
parameters, use the correct function type to avoid indirect call
type mismatches with Control-Flow Integrity checking.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
arch/arm64/include/asm/syscall_wrapper.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h
index a4477e515b798..507d0ee6bc690 100644
--- a/arch/arm64/include/asm/syscall_wrapper.h
+++ b/arch/arm64/include/asm/syscall_wrapper.h
@@ -30,10 +30,10 @@
} \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
-#define COMPAT_SYSCALL_DEFINE0(sname) \
- asmlinkage long __arm64_compat_sys_##sname(void); \
- ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
- asmlinkage long __arm64_compat_sys_##sname(void)
+#define COMPAT_SYSCALL_DEFINE0(sname) \
+ asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \
+ ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
+ asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused)
#define COND_SYSCALL_COMPAT(name) \
cond_syscall(__arm64_compat_sys_##name);
@@ -62,11 +62,11 @@
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#ifndef SYSCALL_DEFINE0
-#define SYSCALL_DEFINE0(sname) \
- SYSCALL_METADATA(_##sname, 0); \
- asmlinkage long __arm64_sys_##sname(void); \
- ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
- asmlinkage long __arm64_sys_##sname(void)
+#define SYSCALL_DEFINE0(sname) \
+ SYSCALL_METADATA(_##sname, 0); \
+ asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \
+ ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
+ asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused)
#endif
#ifndef COND_SYSCALL
--
2.22.0.rc1.257.g3120a18244-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 3/3] arm64: use the correct function type for __arm64_sys_ni_syscall
2019-05-24 22:11 ` Sami Tolvanen
@ 2019-05-24 22:11 ` Sami Tolvanen
-1 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Kees Cook, Nick Desaulniers, linux-arm-kernel, linux-kernel,
Sami Tolvanen
Calling sys_ni_syscall through a syscall_fn_t pointer trips indirect
call Control-Flow Integrity checking due to a function type
mismatch. Use SYSCALL_DEFINE0 for __arm64_sys_ni_syscall instead and
remove the now unnecessary casts.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
arch/arm64/kernel/sys.c | 14 +++++++++-----
arch/arm64/kernel/sys32.c | 7 ++-----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
index 6f91e81165147..d8b35cfe5e94e 100644
--- a/arch/arm64/kernel/sys.c
+++ b/arch/arm64/kernel/sys.c
@@ -47,22 +47,26 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
return ksys_personality(personality);
}
+asmlinkage long sys_ni_syscall(void);
+
+asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused)
+{
+ return sys_ni_syscall();
+}
+
/*
* Wrappers to pass the pt_regs argument.
*/
#define sys_personality sys_arm64_personality
-asmlinkage long sys_ni_syscall(const struct pt_regs *);
-#define __arm64_sys_ni_syscall sys_ni_syscall
-
#undef __SYSCALL
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd.h>
#undef __SYSCALL
-#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym,
+#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
const syscall_fn_t sys_call_table[__NR_syscalls] = {
- [0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
+ [0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall,
#include <asm/unistd.h>
};
diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c
index 0f8bcb7de7008..3c80a40c1c9d6 100644
--- a/arch/arm64/kernel/sys32.c
+++ b/arch/arm64/kernel/sys32.c
@@ -133,17 +133,14 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode,
return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
}
-asmlinkage long sys_ni_syscall(const struct pt_regs *);
-#define __arm64_sys_ni_syscall sys_ni_syscall
-
#undef __SYSCALL
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd32.h>
#undef __SYSCALL
-#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym,
+#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] = {
- [0 ... __NR_compat_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
+ [0 ... __NR_compat_syscalls - 1] = __arm64_sys_ni_syscall,
#include <asm/unistd32.h>
};
--
2.22.0.rc1.257.g3120a18244-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 3/3] arm64: use the correct function type for __arm64_sys_ni_syscall
@ 2019-05-24 22:11 ` Sami Tolvanen
0 siblings, 0 replies; 10+ messages in thread
From: Sami Tolvanen @ 2019-05-24 22:11 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: Sami Tolvanen, Nick Desaulniers, Kees Cook, linux-arm-kernel,
linux-kernel
Calling sys_ni_syscall through a syscall_fn_t pointer trips indirect
call Control-Flow Integrity checking due to a function type
mismatch. Use SYSCALL_DEFINE0 for __arm64_sys_ni_syscall instead and
remove the now unnecessary casts.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
arch/arm64/kernel/sys.c | 14 +++++++++-----
arch/arm64/kernel/sys32.c | 7 ++-----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
index 6f91e81165147..d8b35cfe5e94e 100644
--- a/arch/arm64/kernel/sys.c
+++ b/arch/arm64/kernel/sys.c
@@ -47,22 +47,26 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
return ksys_personality(personality);
}
+asmlinkage long sys_ni_syscall(void);
+
+asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused)
+{
+ return sys_ni_syscall();
+}
+
/*
* Wrappers to pass the pt_regs argument.
*/
#define sys_personality sys_arm64_personality
-asmlinkage long sys_ni_syscall(const struct pt_regs *);
-#define __arm64_sys_ni_syscall sys_ni_syscall
-
#undef __SYSCALL
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd.h>
#undef __SYSCALL
-#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym,
+#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
const syscall_fn_t sys_call_table[__NR_syscalls] = {
- [0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
+ [0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall,
#include <asm/unistd.h>
};
diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c
index 0f8bcb7de7008..3c80a40c1c9d6 100644
--- a/arch/arm64/kernel/sys32.c
+++ b/arch/arm64/kernel/sys32.c
@@ -133,17 +133,14 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode,
return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
}
-asmlinkage long sys_ni_syscall(const struct pt_regs *);
-#define __arm64_sys_ni_syscall sys_ni_syscall
-
#undef __SYSCALL
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd32.h>
#undef __SYSCALL
-#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym,
+#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] = {
- [0 ... __NR_compat_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
+ [0 ... __NR_compat_syscalls - 1] = __arm64_sys_ni_syscall,
#include <asm/unistd32.h>
};
--
2.22.0.rc1.257.g3120a18244-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 0/3] fix function type mismatches in syscall wrappers
2019-05-24 22:11 ` Sami Tolvanen
@ 2019-05-29 15:09 ` Will Deacon
-1 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2019-05-29 15:09 UTC (permalink / raw)
To: Sami Tolvanen
Cc: Catalin Marinas, Mark Rutland, Kees Cook, Nick Desaulniers,
linux-arm-kernel, linux-kernel
On Fri, May 24, 2019 at 03:11:15PM -0700, Sami Tolvanen wrote:
> These patches fix type mismatches in arm64 syscall wrapper
> definitions, which trip indirect call checks with Control-Flow
> Integrity.
>
> Changes in v3:
> - instead of SYSCALL_DEFINE0, just define __arm64_sys_ni_syscall
> with the correct type to avoid unnecessary error injection
Thanks, I've picked this up for -rc3.
Will
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 0/3] fix function type mismatches in syscall wrappers
@ 2019-05-29 15:09 ` Will Deacon
0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2019-05-29 15:09 UTC (permalink / raw)
To: Sami Tolvanen
Cc: Mark Rutland, Kees Cook, Catalin Marinas, Nick Desaulniers,
linux-kernel, linux-arm-kernel
On Fri, May 24, 2019 at 03:11:15PM -0700, Sami Tolvanen wrote:
> These patches fix type mismatches in arm64 syscall wrapper
> definitions, which trip indirect call checks with Control-Flow
> Integrity.
>
> Changes in v3:
> - instead of SYSCALL_DEFINE0, just define __arm64_sys_ni_syscall
> with the correct type to avoid unnecessary error injection
Thanks, I've picked this up for -rc3.
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-05-29 15:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24 22:11 [PATCH v3 0/3] fix function type mismatches in syscall wrappers Sami Tolvanen
2019-05-24 22:11 ` Sami Tolvanen
2019-05-24 22:11 ` [PATCH v3 1/3] arm64: fix syscall_fn_t type Sami Tolvanen
2019-05-24 22:11 ` Sami Tolvanen
2019-05-24 22:11 ` [PATCH v3 2/3] arm64: use the correct function type in SYSCALL_DEFINE0 Sami Tolvanen
2019-05-24 22:11 ` Sami Tolvanen
2019-05-24 22:11 ` [PATCH v3 3/3] arm64: use the correct function type for __arm64_sys_ni_syscall Sami Tolvanen
2019-05-24 22:11 ` Sami Tolvanen
2019-05-29 15:09 ` [PATCH v3 0/3] fix function type mismatches in syscall wrappers Will Deacon
2019-05-29 15:09 ` Will Deacon
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.