From owner-svn-src-user@FreeBSD.ORG Sun Feb 8 20:48:20 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 646A2289; Sun, 8 Feb 2015 20:48:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4F2288FA; Sun, 8 Feb 2015 20:48:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t18KmKej093340; Sun, 8 Feb 2015 20:48:20 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t18KmI3n093332; Sun, 8 Feb 2015 20:48:18 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502082048.t18KmI3n093332@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 8 Feb 2015 20:48:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278401 - in user/dchagin/lemul/sys: amd64/linux amd64/linux32 compat/linux i386/linux X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2015 20:48:20 -0000 Author: dchagin Date: Sun Feb 8 20:48:17 2015 New Revision: 278401 URL: https://svnweb.freebsd.org/changeset/base/278401 Log: According to Linux man sigaltstack(3) shall return EINVAL if the ss argument is not a null pointer, and the ss_flags member pointed to by ss contains flags other than SS_DISABLE. However, in fact, Linux also allows SS_ONSTACK flag which is simply ignored. For buggy apps (at least mono) ignore other than SS_DISABLE flags as a Linux do. While here move MI part of sigaltstack code to the appropriate place. Reported by: abi at abinet dot ru Modified: user/dchagin/lemul/sys/amd64/linux/linux.h user/dchagin/lemul/sys/amd64/linux/linux_machdep.c user/dchagin/lemul/sys/amd64/linux32/linux.h user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c user/dchagin/lemul/sys/compat/linux/linux_signal.c user/dchagin/lemul/sys/compat/linux/linux_signal.h user/dchagin/lemul/sys/i386/linux/linux.h user/dchagin/lemul/sys/i386/linux/linux_machdep.c Modified: user/dchagin/lemul/sys/amd64/linux/linux.h ============================================================================== --- user/dchagin/lemul/sys/amd64/linux/linux.h Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/amd64/linux/linux.h Sun Feb 8 20:48:17 2015 (r278401) @@ -250,9 +250,6 @@ struct l_newstat { #define LINUX_SS_ONSTACK 1 #define LINUX_SS_DISABLE 2 -int linux_to_bsd_sigaltstack(int lsa); -int bsd_to_linux_sigaltstack(int bsa); - typedef void (*l_handler_t)(l_int); typedef struct { Modified: user/dchagin/lemul/sys/amd64/linux/linux_machdep.c ============================================================================== --- user/dchagin/lemul/sys/amd64/linux/linux_machdep.c Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/amd64/linux/linux_machdep.c Sun Feb 8 20:48:17 2015 (r278401) @@ -87,29 +87,6 @@ __FBSDID("$FreeBSD$"); #include #include -int -linux_to_bsd_sigaltstack(int lsa) -{ - int bsa = 0; - - if (lsa & LINUX_SS_DISABLE) - bsa |= SS_DISABLE; - if (lsa & LINUX_SS_ONSTACK) - bsa |= SS_ONSTACK; - return (bsa); -} - -int -bsd_to_linux_sigaltstack(int bsa) -{ - int lsa = 0; - - if (bsa & SS_DISABLE) - lsa |= LINUX_SS_DISABLE; - if (bsa & SS_ONSTACK) - lsa |= LINUX_SS_ONSTACK; - return (lsa); -} int linux_execve(struct thread *td, struct linux_execve_args *args) Modified: user/dchagin/lemul/sys/amd64/linux32/linux.h ============================================================================== --- user/dchagin/lemul/sys/amd64/linux32/linux.h Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/amd64/linux32/linux.h Sun Feb 8 20:48:17 2015 (r278401) @@ -328,9 +328,6 @@ struct l_statfs64 { #define LINUX_SS_ONSTACK 1 #define LINUX_SS_DISABLE 2 -int linux_to_bsd_sigaltstack(int lsa); -int bsd_to_linux_sigaltstack(int bsa); - typedef l_uintptr_t l_handler_t; typedef l_ulong l_osigset_t; Modified: user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c Sun Feb 8 20:48:17 2015 (r278401) @@ -82,34 +82,10 @@ struct l_old_select_argv { l_uintptr_t timeout; } __packed; -int -linux_to_bsd_sigaltstack(int lsa) -{ - int bsa = 0; - - if (lsa & LINUX_SS_DISABLE) - bsa |= SS_DISABLE; - if (lsa & LINUX_SS_ONSTACK) - bsa |= SS_ONSTACK; - return (bsa); -} - static int linux_mmap_common(struct thread *td, l_uintptr_t addr, l_size_t len, l_int prot, l_int flags, l_int fd, l_loff_t pos); -int -bsd_to_linux_sigaltstack(int bsa) -{ - int lsa = 0; - - if (bsa & SS_DISABLE) - lsa |= LINUX_SS_DISABLE; - if (bsa & SS_ONSTACK) - lsa |= LINUX_SS_ONSTACK; - return (lsa); -} - static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru) { Modified: user/dchagin/lemul/sys/compat/linux/linux_signal.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_signal.c Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/compat/linux/linux_signal.c Sun Feb 8 20:48:17 2015 (r278401) @@ -683,6 +683,32 @@ sicode_to_lsicode(int si_code, int *lsi_ } } +int +linux_to_bsd_sigaltstack(int lsa) +{ + int bsa = 0; + + if (lsa & LINUX_SS_DISABLE) + bsa |= SS_DISABLE; + /* + * Linux ignores SS_ONSTACK flag for ss + * parameter while FreeBSD prohibits it. + */ + return (bsa); +} + +int +bsd_to_linux_sigaltstack(int bsa) +{ + int lsa = 0; + + if (bsa & SS_DISABLE) + lsa |= LINUX_SS_DISABLE; + if (bsa & SS_ONSTACK) + lsa |= LINUX_SS_ONSTACK; + return (lsa); +} + void lsiginfo_to_ksiginfo(l_siginfo_t *lsi, ksiginfo_t *ksi, int sig) { Modified: user/dchagin/lemul/sys/compat/linux/linux_signal.h ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_signal.h Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/compat/linux/linux_signal.h Sun Feb 8 20:48:17 2015 (r278401) @@ -46,6 +46,8 @@ extern int bsd_to_linux_signal[]; extern int linux_to_bsd_signal[]; +int linux_to_bsd_sigaltstack(int lsa); +int bsd_to_linux_sigaltstack(int bsa); void linux_to_bsd_sigset(l_sigset_t *, sigset_t *); void bsd_to_linux_sigset(sigset_t *, l_sigset_t *); int linux_do_sigaction(struct thread *, int, l_sigaction_t *, l_sigaction_t *); Modified: user/dchagin/lemul/sys/i386/linux/linux.h ============================================================================== --- user/dchagin/lemul/sys/i386/linux/linux.h Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/i386/linux/linux.h Sun Feb 8 20:48:17 2015 (r278401) @@ -303,9 +303,6 @@ struct l_statfs64 { #define LINUX_SS_ONSTACK 1 #define LINUX_SS_DISABLE 2 -int linux_to_bsd_sigaltstack(int lsa); -int bsd_to_linux_sigaltstack(int bsa); - typedef void (*l_handler_t)(l_int); typedef l_ulong l_osigset_t; Modified: user/dchagin/lemul/sys/i386/linux/linux_machdep.c ============================================================================== --- user/dchagin/lemul/sys/i386/linux/linux_machdep.c Sun Feb 8 20:44:50 2015 (r278400) +++ user/dchagin/lemul/sys/i386/linux/linux_machdep.c Sun Feb 8 20:48:17 2015 (r278401) @@ -99,29 +99,6 @@ static int linux_mmap_common(struct thre l_size_t len, l_int prot, l_int flags, l_int fd, l_loff_t pos); -int -linux_to_bsd_sigaltstack(int lsa) -{ - int bsa = 0; - - if (lsa & LINUX_SS_DISABLE) - bsa |= SS_DISABLE; - if (lsa & LINUX_SS_ONSTACK) - bsa |= SS_ONSTACK; - return (bsa); -} - -int -bsd_to_linux_sigaltstack(int bsa) -{ - int lsa = 0; - - if (bsa & SS_DISABLE) - lsa |= LINUX_SS_DISABLE; - if (bsa & SS_ONSTACK) - lsa |= LINUX_SS_ONSTACK; - return (lsa); -} int linux_execve(struct thread *td, struct linux_execve_args *args)