From: Christoph Hellwig <hch@lst.de> To: Andrew Morton <akpm@linux-foundation.org>, Alexander Viro <viro@zeniv.linux.org.uk> Cc: Jeremy Kerr <jk@ozlabs.org>, Arnd Bergmann <arnd@arndb.de>, "Eric W . Biederman" <ebiederm@xmission.com>, linuxppc-dev@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] signal: clean up __copy_siginfo_to_user32 Date: Tue, 14 Apr 2020 09:01:36 +0200 [thread overview] Message-ID: <20200414070142.288696-3-hch@lst.de> (raw) In-Reply-To: <20200414070142.288696-1-hch@lst.de> Instead of an architecture specific calling convention in common code just pass a flags argument with architecture specific values. Signed-off-by: Christoph Hellwig <hch@lst.de> --- arch/x86/ia32/ia32_signal.c | 2 +- arch/x86/include/asm/compat.h | 4 ---- arch/x86/include/asm/signal.h | 3 +++ arch/x86/kernel/signal.c | 3 ++- include/linux/compat.h | 2 ++ kernel/signal.c | 21 ++++++++++++--------- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index f9d8804144d0..2bf188942d5c 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -350,7 +350,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig, unsafe_put_user(*(__u64 *)set, (__u64 *)&frame->uc.uc_sigmask, Efault); user_access_end(); - if (__copy_siginfo_to_user32(&frame->info, &ksig->info, false)) + if (__copy_siginfo_to_user32(&frame->info, &ksig->info, SA_IA32_ABI)) return -EFAULT; /* Set up registers for signal handler */ diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 52e9f3480f69..a787c9a82030 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -213,8 +213,4 @@ static inline bool in_compat_syscall(void) #define in_compat_syscall in_compat_syscall /* override the generic impl */ #endif -struct compat_siginfo; -int __copy_siginfo_to_user32(struct compat_siginfo __user *to, - const kernel_siginfo_t *from, bool x32_ABI); - #endif /* _ASM_X86_COMPAT_H */ diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h index 33d3c88a7225..b3f7a14da428 100644 --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h @@ -28,6 +28,9 @@ typedef struct { #define SA_IA32_ABI 0x02000000u #define SA_X32_ABI 0x01000000u +#define compat_siginfo_flags() \ + (in_x32_syscall() ? SA_X32_ABI : SA_IA32_ABI) + #ifndef CONFIG_COMPAT typedef sigset_t compat_sigset_t; #endif diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 83b74fb38c8f..bbd451631790 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -543,7 +543,8 @@ static int x32_setup_rt_frame(struct ksignal *ksig, user_access_end(); if (ksig->ka.sa.sa_flags & SA_SIGINFO) { - if (__copy_siginfo_to_user32(&frame->info, &ksig->info, true)) + if (__copy_siginfo_to_user32(&frame->info, &ksig->info, + SA_X32_ABI)) return -EFAULT; } diff --git a/include/linux/compat.h b/include/linux/compat.h index 0480ba4db592..14eec6116110 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -404,6 +404,8 @@ long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, unsigned long bitmap_size); int copy_siginfo_from_user32(kernel_siginfo_t *to, const struct compat_siginfo __user *from); int copy_siginfo_to_user32(struct compat_siginfo __user *to, const kernel_siginfo_t *from); +int __copy_siginfo_to_user32(struct compat_siginfo __user *to, + const kernel_siginfo_t *from, unsigned int flags); int get_compat_sigevent(struct sigevent *event, const struct compat_sigevent __user *u_event); diff --git a/kernel/signal.c b/kernel/signal.c index e58a6c619824..092fee008242 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3235,15 +3235,8 @@ int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from) } #ifdef CONFIG_COMPAT -int copy_siginfo_to_user32(struct compat_siginfo __user *to, - const struct kernel_siginfo *from) -#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION) -{ - return __copy_siginfo_to_user32(to, from, in_x32_syscall()); -} int __copy_siginfo_to_user32(struct compat_siginfo __user *to, - const struct kernel_siginfo *from, bool x32_ABI) -#endif + const struct kernel_siginfo *from, unsigned int flags) { struct compat_siginfo new; memset(&new, 0, sizeof(new)); @@ -3298,7 +3291,7 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to, new.si_uid = from->si_uid; new.si_status = from->si_status; #ifdef CONFIG_X86_X32_ABI - if (x32_ABI) { + if (flags & SA_X32_ABI) { new._sifields._sigchld_x32._utime = from->si_utime; new._sifields._sigchld_x32._stime = from->si_stime; } else @@ -3326,6 +3319,16 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to, return 0; } +#ifndef compat_siginfo_flags +#define compat_siginfo_flags() 0 +#endif + +int copy_siginfo_to_user32(struct compat_siginfo __user *to, + const struct kernel_siginfo *from) +{ + return __copy_siginfo_to_user32(to, from, compat_siginfo_flags()); +} + static int post_copy_siginfo_from_user32(kernel_siginfo_t *to, const struct compat_siginfo *from) { -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de> To: Andrew Morton <akpm@linux-foundation.org>, Alexander Viro <viro@zeniv.linux.org.uk> Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org, Jeremy Kerr <jk@ozlabs.org>, linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Eric W . Biederman" <ebiederm@xmission.com> Subject: [PATCH 2/8] signal: clean up __copy_siginfo_to_user32 Date: Tue, 14 Apr 2020 09:01:36 +0200 [thread overview] Message-ID: <20200414070142.288696-3-hch@lst.de> (raw) In-Reply-To: <20200414070142.288696-1-hch@lst.de> Instead of an architecture specific calling convention in common code just pass a flags argument with architecture specific values. Signed-off-by: Christoph Hellwig <hch@lst.de> --- arch/x86/ia32/ia32_signal.c | 2 +- arch/x86/include/asm/compat.h | 4 ---- arch/x86/include/asm/signal.h | 3 +++ arch/x86/kernel/signal.c | 3 ++- include/linux/compat.h | 2 ++ kernel/signal.c | 21 ++++++++++++--------- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index f9d8804144d0..2bf188942d5c 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -350,7 +350,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig, unsafe_put_user(*(__u64 *)set, (__u64 *)&frame->uc.uc_sigmask, Efault); user_access_end(); - if (__copy_siginfo_to_user32(&frame->info, &ksig->info, false)) + if (__copy_siginfo_to_user32(&frame->info, &ksig->info, SA_IA32_ABI)) return -EFAULT; /* Set up registers for signal handler */ diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 52e9f3480f69..a787c9a82030 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -213,8 +213,4 @@ static inline bool in_compat_syscall(void) #define in_compat_syscall in_compat_syscall /* override the generic impl */ #endif -struct compat_siginfo; -int __copy_siginfo_to_user32(struct compat_siginfo __user *to, - const kernel_siginfo_t *from, bool x32_ABI); - #endif /* _ASM_X86_COMPAT_H */ diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h index 33d3c88a7225..b3f7a14da428 100644 --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h @@ -28,6 +28,9 @@ typedef struct { #define SA_IA32_ABI 0x02000000u #define SA_X32_ABI 0x01000000u +#define compat_siginfo_flags() \ + (in_x32_syscall() ? SA_X32_ABI : SA_IA32_ABI) + #ifndef CONFIG_COMPAT typedef sigset_t compat_sigset_t; #endif diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 83b74fb38c8f..bbd451631790 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -543,7 +543,8 @@ static int x32_setup_rt_frame(struct ksignal *ksig, user_access_end(); if (ksig->ka.sa.sa_flags & SA_SIGINFO) { - if (__copy_siginfo_to_user32(&frame->info, &ksig->info, true)) + if (__copy_siginfo_to_user32(&frame->info, &ksig->info, + SA_X32_ABI)) return -EFAULT; } diff --git a/include/linux/compat.h b/include/linux/compat.h index 0480ba4db592..14eec6116110 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -404,6 +404,8 @@ long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, unsigned long bitmap_size); int copy_siginfo_from_user32(kernel_siginfo_t *to, const struct compat_siginfo __user *from); int copy_siginfo_to_user32(struct compat_siginfo __user *to, const kernel_siginfo_t *from); +int __copy_siginfo_to_user32(struct compat_siginfo __user *to, + const kernel_siginfo_t *from, unsigned int flags); int get_compat_sigevent(struct sigevent *event, const struct compat_sigevent __user *u_event); diff --git a/kernel/signal.c b/kernel/signal.c index e58a6c619824..092fee008242 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3235,15 +3235,8 @@ int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from) } #ifdef CONFIG_COMPAT -int copy_siginfo_to_user32(struct compat_siginfo __user *to, - const struct kernel_siginfo *from) -#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION) -{ - return __copy_siginfo_to_user32(to, from, in_x32_syscall()); -} int __copy_siginfo_to_user32(struct compat_siginfo __user *to, - const struct kernel_siginfo *from, bool x32_ABI) -#endif + const struct kernel_siginfo *from, unsigned int flags) { struct compat_siginfo new; memset(&new, 0, sizeof(new)); @@ -3298,7 +3291,7 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to, new.si_uid = from->si_uid; new.si_status = from->si_status; #ifdef CONFIG_X86_X32_ABI - if (x32_ABI) { + if (flags & SA_X32_ABI) { new._sifields._sigchld_x32._utime = from->si_utime; new._sifields._sigchld_x32._stime = from->si_stime; } else @@ -3326,6 +3319,16 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to, return 0; } +#ifndef compat_siginfo_flags +#define compat_siginfo_flags() 0 +#endif + +int copy_siginfo_to_user32(struct compat_siginfo __user *to, + const struct kernel_siginfo *from) +{ + return __copy_siginfo_to_user32(to, from, compat_siginfo_flags()); +} + static int post_copy_siginfo_from_user32(kernel_siginfo_t *to, const struct compat_siginfo *from) { -- 2.25.1
next prev parent reply other threads:[~2020-04-14 7:03 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-14 7:01 remove set_fs calls from the exec and coredump code v2 Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 7:01 ` [PATCH 1/8] powerpc/spufs: simplify spufs core dumping Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig [this message] 2020-04-14 7:01 ` [PATCH 2/8] signal: clean up __copy_siginfo_to_user32 Christoph Hellwig 2020-04-17 21:08 ` Eric W. Biederman 2020-04-17 21:08 ` Eric W. Biederman 2020-04-17 21:09 ` [PATCH 1/2] signal: Factor copy_siginfo_to_external32 from copy_siginfo_to_user32 Eric W. Biederman 2020-04-17 21:09 ` Eric W. Biederman 2020-04-18 8:05 ` Christophe Leroy 2020-04-18 11:55 ` Eric W. Biederman 2020-04-18 11:55 ` Eric W. Biederman 2020-04-19 8:13 ` Christoph Hellwig 2020-04-19 8:13 ` Christoph Hellwig 2020-04-19 9:46 ` Christophe Leroy 2020-04-19 9:54 ` Christophe Leroy 2020-04-19 8:05 ` Christoph Hellwig 2020-04-19 8:05 ` Christoph Hellwig 2020-04-17 21:09 ` [PATCH 2/2] signal: Remove the set_fs in binfmt_elf.c:fill_siginfo_note Eric W. Biederman 2020-04-17 21:09 ` Eric W. Biederman 2020-04-19 8:03 ` [PATCH 2/8] signal: clean up __copy_siginfo_to_user32 Christoph Hellwig 2020-04-19 8:03 ` Christoph Hellwig 2020-04-14 7:01 ` [PATCH 3/8] signal: replace __copy_siginfo_to_user32 with to_compat_siginfo Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 14:00 ` Arnd Bergmann 2020-04-14 14:00 ` Arnd Bergmann 2020-04-14 7:01 ` [PATCH 4/8] binfmt_elf: open code copy_siginfo_to_user to kernelspace buffer Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 13:15 ` Arnd Bergmann 2020-04-14 13:15 ` Arnd Bergmann 2020-04-15 7:45 ` Christoph Hellwig 2020-04-15 7:45 ` Christoph Hellwig 2020-04-15 8:20 ` Arnd Bergmann 2020-04-15 8:20 ` Arnd Bergmann 2020-04-17 13:27 ` Christoph Hellwig 2020-04-17 13:27 ` Christoph Hellwig 2020-04-17 18:10 ` Eric W. Biederman 2020-04-17 18:10 ` Eric W. Biederman 2020-04-17 20:06 ` Arnd Bergmann 2020-04-17 20:06 ` Arnd Bergmann 2020-04-15 3:01 ` Michael Ellerman 2020-04-15 3:01 ` Michael Ellerman 2020-04-15 6:19 ` Christoph Hellwig 2020-04-15 6:19 ` Christoph Hellwig 2020-04-14 7:01 ` [PATCH 5/8] binfmt_elf: remove the set_fs(KERNEL_DS) in elf_core_dump Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 7:01 ` [PATCH 6/8] binfmt_elf_fdpic: remove the set_fs(KERNEL_DS) in elf_fdpic_core_dump Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 7:01 ` [PATCH 7/8] exec: simplify the copy_strings_kernel calling convention Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-14 7:01 ` [PATCH 8/8] exec: open code copy_string_kernel Christoph Hellwig 2020-04-14 7:01 ` Christoph Hellwig 2020-04-18 8:15 ` Christophe Leroy 2020-04-18 8:15 ` Christophe Leroy 2020-04-19 8:06 ` Christoph Hellwig 2020-04-19 8:06 ` Christoph Hellwig 2020-04-19 9:44 ` Christophe Leroy 2020-04-19 9:44 ` Christophe Leroy 2020-04-17 22:41 ` remove set_fs calls from the exec and coredump code v2 Eric W. Biederman 2020-04-17 22:41 ` Eric W. Biederman 2020-04-19 8:19 ` Christoph Hellwig 2020-04-19 8:19 ` Christoph Hellwig 2020-04-19 11:50 ` Eric W. Biederman 2020-04-19 11:50 ` Eric W. Biederman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200414070142.288696-3-hch@lst.de \ --to=hch@lst.de \ --cc=akpm@linux-foundation.org \ --cc=arnd@arndb.de \ --cc=ebiederm@xmission.com \ --cc=jk@ozlabs.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=viro@zeniv.linux.org.uk \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.