Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 17:44:09 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283471 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux
Message-ID:  <201505241744.t4OHi9jN029735@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May 24 17:44:08 2015
New Revision: 283471
URL: https://svnweb.freebsd.org/changeset/base/283471

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:
  head/sys/amd64/linux/linux.h
  head/sys/amd64/linux/linux_machdep.c
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linux/linux_signal.c
  head/sys/compat/linux/linux_signal.h
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux/linux.h
==============================================================================
--- head/sys/amd64/linux/linux.h	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/amd64/linux/linux.h	Sun May 24 17:44:08 2015	(r283471)
@@ -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: head/sys/amd64/linux/linux_machdep.c
==============================================================================
--- head/sys/amd64/linux/linux_machdep.c	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/amd64/linux/linux_machdep.c	Sun May 24 17:44:08 2015	(r283471)
@@ -87,29 +87,6 @@ __FBSDID("$FreeBSD$");
 #include <compat/linux/linux_util.h>
 #include <compat/linux/linux_emul.h>
 
-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: head/sys/amd64/linux32/linux.h
==============================================================================
--- head/sys/amd64/linux32/linux.h	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/amd64/linux32/linux.h	Sun May 24 17:44:08 2015	(r283471)
@@ -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: head/sys/amd64/linux32/linux32_machdep.c
==============================================================================
--- head/sys/amd64/linux32/linux32_machdep.c	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/amd64/linux32/linux32_machdep.c	Sun May 24 17:44:08 2015	(r283471)
@@ -84,34 +84,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: head/sys/compat/linux/linux_signal.c
==============================================================================
--- head/sys/compat/linux/linux_signal.c	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/compat/linux/linux_signal.c	Sun May 24 17:44:08 2015	(r283471)
@@ -754,6 +754,32 @@ siginfo_to_lsiginfo(const siginfo_t *si,
 	}
 }
 
+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(const l_siginfo_t *lsi, ksiginfo_t *ksi, int sig)
 {

Modified: head/sys/compat/linux/linux_signal.h
==============================================================================
--- head/sys/compat/linux/linux_signal.h	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/compat/linux/linux_signal.h	Sun May 24 17:44:08 2015	(r283471)
@@ -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: head/sys/i386/linux/linux.h
==============================================================================
--- head/sys/i386/linux/linux.h	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/i386/linux/linux.h	Sun May 24 17:44:08 2015	(r283471)
@@ -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: head/sys/i386/linux/linux_machdep.c
==============================================================================
--- head/sys/i386/linux/linux_machdep.c	Sun May 24 17:42:45 2015	(r283470)
+++ head/sys/i386/linux/linux_machdep.c	Sun May 24 17:44:08 2015	(r283471)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505241744.t4OHi9jN029735>