* [PATCH] um: Cleanup syscall_handler_t definition/cast, fix warning
@ 2022-02-10 3:43 David Gow
2022-02-17 17:29 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: David Gow @ 2022-02-10 3:43 UTC (permalink / raw)
To: Jeff Dike, Richard Weinberger, Anton Ivanov, Al Viro
Cc: David Gow, x86, linux-um, linux-kernel
The syscall_handler_t type for x86_64 was defined as 'long (*)(void)',
but always cast to 'long (*)(long, long, long, long, long, long)' before
use. This now triggers a warning (see below).
Define syscall_handler_t as the latter instead, and remove the cast.
This simplifies the code, and fixes the warning.
Warning:
In file included from ../arch/um/include/asm/processor-generic.h:13
from ../arch/x86/um/asm/processor.h:41
from ../include/linux/rcupdate.h:30
from ../include/linux/rculist.h:11
from ../include/linux/pid.h:5
from ../include/linux/sched.h:14
from ../include/linux/ptrace.h:6
from ../arch/um/kernel/skas/syscall.c:7:
../arch/um/kernel/skas/syscall.c: In function ‘handle_syscall’:
../arch/x86/um/shared/sysdep/syscalls_64.h:18:11: warning: cast between incompatible function types from ‘long int (*)(void)’ to ‘long int (*)(long int, long int, long int, long int, long int, long int)’ [
-Wcast-function-type]
18 | (((long (*)(long, long, long, long, long, long)) \
| ^
../arch/x86/um/asm/ptrace.h:36:62: note: in definition of macro ‘PT_REGS_SET_SYSCALL_RETURN’
36 | #define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
| ^~~
../arch/um/kernel/skas/syscall.c:46:33: note: in expansion of macro ‘EXECUTE_SYSCALL’
46 | EXECUTE_SYSCALL(syscall, regs));
| ^~~~~~~~~~~~~~~
Signed-off-by: David Gow <davidgow@google.com>
---
I couldn't find a reason for the two conflicting function types here,
but it's possible I'm missing one. At the very least, this change didn't
seem to break anything on my system.
arch/x86/um/shared/sysdep/syscalls_64.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/x86/um/shared/sysdep/syscalls_64.h b/arch/x86/um/shared/sysdep/syscalls_64.h
index 48d6cd12f8a5..b6b997225841 100644
--- a/arch/x86/um/shared/sysdep/syscalls_64.h
+++ b/arch/x86/um/shared/sysdep/syscalls_64.h
@@ -10,13 +10,12 @@
#include <linux/msg.h>
#include <linux/shm.h>
-typedef long syscall_handler_t(void);
+typedef long syscall_handler_t(long, long, long, long, long, long);
extern syscall_handler_t *sys_call_table[];
#define EXECUTE_SYSCALL(syscall, regs) \
- (((long (*)(long, long, long, long, long, long)) \
- (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(®s->regs), \
+ (((*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(®s->regs), \
UPT_SYSCALL_ARG2(®s->regs), \
UPT_SYSCALL_ARG3(®s->regs), \
UPT_SYSCALL_ARG4(®s->regs), \
--
2.35.0.263.gb82422642f-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] um: Cleanup syscall_handler_t definition/cast, fix warning
2022-02-10 3:43 [PATCH] um: Cleanup syscall_handler_t definition/cast, fix warning David Gow
@ 2022-02-17 17:29 ` Kees Cook
0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2022-02-17 17:29 UTC (permalink / raw)
To: David Gow
Cc: Jeff Dike, Richard Weinberger, Anton Ivanov, Al Viro, x86,
linux-um, linux-kernel
On Thu, Feb 10, 2022 at 11:43:53AM +0800, David Gow wrote:
> The syscall_handler_t type for x86_64 was defined as 'long (*)(void)',
> but always cast to 'long (*)(long, long, long, long, long, long)' before
> use. This now triggers a warning (see below).
>
> Define syscall_handler_t as the latter instead, and remove the cast.
> This simplifies the code, and fixes the warning.
>
> Warning:
> In file included from ../arch/um/include/asm/processor-generic.h:13
> from ../arch/x86/um/asm/processor.h:41
> from ../include/linux/rcupdate.h:30
> from ../include/linux/rculist.h:11
> from ../include/linux/pid.h:5
> from ../include/linux/sched.h:14
> from ../include/linux/ptrace.h:6
> from ../arch/um/kernel/skas/syscall.c:7:
> ../arch/um/kernel/skas/syscall.c: In function ‘handle_syscall’:
> ../arch/x86/um/shared/sysdep/syscalls_64.h:18:11: warning: cast between incompatible function types from ‘long int (*)(void)’ to ‘long int (*)(long int, long int, long int, long int, long int, long int)’ [
> -Wcast-function-type]
> 18 | (((long (*)(long, long, long, long, long, long)) \
> | ^
> ../arch/x86/um/asm/ptrace.h:36:62: note: in definition of macro ‘PT_REGS_SET_SYSCALL_RETURN’
> 36 | #define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
> | ^~~
> ../arch/um/kernel/skas/syscall.c:46:33: note: in expansion of macro ‘EXECUTE_SYSCALL’
> 46 | EXECUTE_SYSCALL(syscall, regs));
> | ^~~~~~~~~~~~~~~
>
> Signed-off-by: David Gow <davidgow@google.com>
Thanks for this! I was just about to go figure this out too. :)
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-17 17:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 3:43 [PATCH] um: Cleanup syscall_handler_t definition/cast, fix warning David Gow
2022-02-17 17:29 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).