summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2015-05-24 17:44:08 +0000
committerdchagin <dchagin@FreeBSD.org>2015-05-24 17:44:08 +0000
commitcace25f46d7edf921baabc4101df2d4912430748 (patch)
tree1882a742118caa04116b2336dcabc078038cb933
parent73fcf6f585554f1aeddfcb85080a459d68167fc8 (diff)
downloadFreeBSD-src-cace25f46d7edf921baabc4101df2d4912430748.zip
FreeBSD-src-cace25f46d7edf921baabc4101df2d4912430748.tar.gz
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
-rw-r--r--sys/amd64/linux/linux.h3
-rw-r--r--sys/amd64/linux/linux_machdep.c23
-rw-r--r--sys/amd64/linux32/linux.h3
-rw-r--r--sys/amd64/linux32/linux32_machdep.c24
-rw-r--r--sys/compat/linux/linux_signal.c26
-rw-r--r--sys/compat/linux/linux_signal.h2
-rw-r--r--sys/i386/linux/linux.h3
-rw-r--r--sys/i386/linux/linux_machdep.c23
8 files changed, 28 insertions, 79 deletions
diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h
index 0845809..b4e7190 100644
--- a/sys/amd64/linux/linux.h
+++ b/sys/amd64/linux/linux.h
@@ -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 {
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
index d8704fd..8b0da51 100644
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -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)
diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h
index 001c86b..d76b44c 100644
--- a/sys/amd64/linux32/linux.h
+++ b/sys/amd64/linux32/linux.h
@@ -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;
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index 4ecbef2..d84e58e 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -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)
{
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index 856d433..f60e731 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -754,6 +754,32 @@ siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig)
}
}
+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)
{
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
index 21b557a..eb06bb0 100644
--- a/sys/compat/linux/linux_signal.h
+++ b/sys/compat/linux/linux_signal.h
@@ -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 *);
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index 3087dac..ae12499 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -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;
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index cd8bf0d..7c663e5 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -99,29 +99,6 @@ 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
-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)
OpenPOWER on IntegriCloud