From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B865C2BA19 for ; Tue, 14 Apr 2020 07:03:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22F0120735 for ; Tue, 14 Apr 2020 07:03:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="h03I+MhQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406293AbgDNHDe (ORCPT ); Tue, 14 Apr 2020 03:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406217AbgDNHCH (ORCPT ); Tue, 14 Apr 2020 03:02:07 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DD73C008749 for ; Tue, 14 Apr 2020 00:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QyqnUQtfDFl3dc+js9JidTVXyT5mrcvSlGDN+l8Z+e0=; b=h03I+MhQk5B0Cpg9C3gZwoZ+ba fZ1CRCN2QFN0vzBDTXxijJh/4MIeNc8xosC03P/4JKTQ/qF+MtmEkUr2kLtyOklV00vpTe0MKghev 3H2XPH8aR9g4ZZxJZoZQ5MaH+EbmunF2DT66HMngN8CbvXQQk2Aut/4sY/Y7kaHpIGLum5lGOFT/L uWe2JJyD7JUmNLOwjFeZORkPDtqNZMxzv7TR7VeC8eLPnerV12PRgbBnyPqhP1xb6I2OKLY9zD0vf N+QhGvXpn+qxQRZ0lOOLAFzkAXYrvYzvAvI70OYDgLkH4a7J5euk3myUyvFWwLXajRwKYqSTueTZH DvYa/l1Q==; Received: from [2001:4bb8:180:384b:4c21:af7:dd95:e552] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jOFZu-0005YD-Nm; Tue, 14 Apr 2020 07:01:51 +0000 From: Christoph Hellwig To: Andrew Morton , Alexander Viro Cc: Jeremy Kerr , Arnd Bergmann , "Eric W . Biederman" , 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 Message-Id: <20200414070142.288696-3-hch@lst.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414070142.288696-1-hch@lst.de> References: <20200414070142.288696-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of an architecture specific calling convention in common code just pass a flags argument with architecture specific values. Signed-off-by: Christoph Hellwig --- 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