mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] bring sparc{64} into the generic siginfo fold
  2002-10-10  5:43 [PATCH] bring sparc{64} into the generic siginfo fold Stephen Rothwell
@ 2002-10-10  5:42 ` David S. Miller
  2002-10-10  6:07   ` Stephen Rothwell
  0 siblings, 1 reply; 3+ messages in thread
From: David S. Miller @ 2002-10-10  5:42 UTC (permalink / raw)
  To: sfr; +Cc: linux-kernel, anton

   From: Stephen Rothwell <sfr@canb.auug.org.au>
   Date: Thu, 10 Oct 2002 15:43:32 +1000

   This patch (uncompiled, untested) enables sparc and sparc64 to use
   the gerneic siginfo structure.  Hope you like it :-)
   
Thanks I'll have a look :)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] bring sparc{64} into the generic siginfo fold
@ 2002-10-10  5:43 Stephen Rothwell
  2002-10-10  5:42 ` David S. Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Rothwell @ 2002-10-10  5:43 UTC (permalink / raw)
  To: davem; +Cc: LKML, anton

Hi Dave,

This patch (uncompiled, untested) enables sparc and sparc64 to use
the gerneic siginfo structure.  Hope you like it :-)

diffstat:
 asm-generic/siginfo.h |   28 +++++++++++++++----
 asm-sparc/siginfo.h   |   71 +------------------------------------------------
 asm-sparc64/siginfo.h |   72 +-------------------------------------------------
3 files changed, 27 insertions(+), 144 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.41-1.747/include/asm-generic/siginfo.h 2.5.41-1.747-si.1/include/asm-generic/siginfo.h
--- 2.5.41-1.747/include/asm-generic/siginfo.h	2002-10-10 14:31:49.000000000 +1000
+++ 2.5.41-1.747-si.1/include/asm-generic/siginfo.h	2002-10-10 15:27:26.000000000 +1000
@@ -8,9 +8,21 @@
 	void *sival_ptr;
 } sigval_t;
 
+/*
+ * This is the size (including padding) of the part of the
+ * struct siginfo that is before the union.
+ */
+#ifndef __ARCH_SI_PREAMBLE_SIZE
+#define __ARCH_SI_PREAMBLE_SIZE	(3 * sizeof(int))
+#endif
+
 #define SI_MAX_SIZE	128
 #ifndef SI_PAD_SIZE
-#define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 3)
+#define SI_PAD_SIZE	((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
+#endif
+
+#ifndef __ARCH_SI_UID_T
+#define __ARCH_SI_UID_T	uid_t
 #endif
 
 #ifndef HAVE_ARCH_SIGINFO_T
@@ -26,7 +38,7 @@
 		/* kill() */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			uid_t _uid;		/* sender's uid */
+			__ARCH_SI_UID_T _uid;	/* sender's uid */
 		} _kill;
 
 		/* POSIX.1b timers */
@@ -38,14 +50,14 @@
 		/* POSIX.1b signals */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			uid_t _uid;		/* sender's uid */
+			__ARCH_SI_UID_T _uid;	/* sender's uid */
 			sigval_t _sigval;
 		} _rt;
 
 		/* SIGCHLD */
 		struct {
 			pid_t _pid;		/* which child */
-			uid_t _uid;		/* sender's uid */
+			__ARCH_SI_UID_T _uid;	/* sender's uid */
 			int _status;		/* exit code */
 			clock_t _utime;
 			clock_t _stime;
@@ -54,6 +66,9 @@
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
 		struct {
 			void *_addr; /* faulting insn/memory ref. */
+#ifdef __ARCH_SI_TRAPNO
+			int _trapno;	/* TRAP # which caused the signal */
+#endif
 		} _sigfault;
 
 		/* SIGPOLL */
@@ -80,6 +95,9 @@
 #define si_int		_sifields._rt._sigval.sival_int
 #define si_ptr		_sifields._rt._sigval.sival_ptr
 #define si_addr		_sifields._sigfault._addr
+#ifdef __ARCH_SI_TRAPNO
+#define si_trapno	_sifields._sigfault._trapno
+#endif
 #define si_band		_sifields._sigpoll._band
 #define si_fd		_sifields._sigpoll._fd
 
@@ -244,7 +262,7 @@
 		memcpy(to, from, sizeof(*to));
 	else
 		/* _sigchld is currently the largest know union member */
-		memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
+		memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
 }
 
 #endif
diff -ruN 2.5.41-1.747/include/asm-sparc/siginfo.h 2.5.41-1.747-si.1/include/asm-sparc/siginfo.h
--- 2.5.41-1.747/include/asm-sparc/siginfo.h	2002-06-03 12:13:01.000000000 +1000
+++ 2.5.41-1.747-si.1/include/asm-sparc/siginfo.h	2002-10-10 15:17:50.000000000 +1000
@@ -5,64 +5,12 @@
 #ifndef _SPARC_SIGINFO_H
 #define _SPARC_SIGINFO_H
 
-#define HAVE_ARCH_SIGINFO_T
-#define HAVE_ARCH_COPY_SIGINFO
+#define __ARCH_SI_UID_T		unsigned int
+#define __ARCH_SI_TRAPNO
 #define HAVE_ARCH_COPY_SIGINFO_TO_USER
 
 #include <asm-generic/siginfo.h>
 
-typedef struct siginfo {
-	int si_signo;
-	int si_errno;
-	int si_code;
-
-	union {
-		int _pad[SI_PAD_SIZE];
-
-		/* kill() */
-		struct {
-			pid_t _pid;		/* sender's pid */
-			unsigned int _uid;	/* sender's uid */
-		} _kill;
-
-		/* POSIX.1b timers */
-		struct {
-			unsigned int _timer1;
-			unsigned int _timer2;
-		} _timer;
-
-		/* POSIX.1b signals */
-		struct {
-			pid_t _pid;		/* sender's pid */
-			unsigned int _uid;	/* sender's uid */
-			sigval_t _sigval;
-		} _rt;
-
-		/* SIGCHLD */
-		struct {
-			pid_t _pid;		/* which child */
-			unsigned int _uid;	/* sender's uid */
-			int _status;		/* exit code */
-			clock_t _utime;
-			clock_t _stime;
-		} _sigchld;
-
-		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
-		struct {
-			void *_addr;	/* faulting insn/memory ref. */
-			int  _trapno;	/* TRAP # which caused the signal */
-		} _sigfault;
-
-		/* SIGPOLL */
-		struct {
-			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
-			int _fd;
-		} _sigpoll;
-	} _sifields;
-} siginfo_t;
-
-#define si_trapno	_sifields._sigfault._trapno
-
 #define SI_NOINFO	32767		/* no information in siginfo_t */
 
 /*
@@ -71,19 +19,4 @@
 #define EMT_TAGOVF	(__SI_FAULT|1)	/* tag overflow */
 #define NSIGEMT		1
 
-#ifdef __KERNEL__
-
-#include <linux/string.h>
-
-extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from)
-{
-	if (from->si_code < 0)
-		*to = *from;
-	else
-		/* _sigchld is currently the largest know union member */
-		memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
-}
-
-#endif /* __KERNEL__ */
-
 #endif /* !(_SPARC_SIGINFO_H) */
diff -ruN 2.5.41-1.747/include/asm-sparc64/siginfo.h 2.5.41-1.747-si.1/include/asm-sparc64/siginfo.h
--- 2.5.41-1.747/include/asm-sparc64/siginfo.h	2002-10-08 12:02:59.000000000 +1000
+++ 2.5.41-1.747-si.1/include/asm-sparc64/siginfo.h	2002-10-10 15:29:34.000000000 +1000
@@ -1,14 +1,13 @@
 #ifndef _SPARC64_SIGINFO_H
 #define _SPARC64_SIGINFO_H
 
-#define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 4)
 #define SI_PAD_SIZE32	((SI_MAX_SIZE/sizeof(int)) - 3)
 
 #define SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE/sizeof(int)) - 4)
 #define SIGEV_PAD_SIZE32 ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
 
-#define HAVE_ARCH_SIGINFO_T
-#define HAVE_ARCH_COPY_SIGINFO
+#define __ARCH_SI_PREAMBLE_SIZE	(4 * sizeof(int))
+#define __ARCH_SI_TRAPNO
 #define HAVE_ARCH_COPY_SIGINFO_TO_USER
 
 #include <asm-generic/siginfo.h>
@@ -20,60 +19,6 @@
 	u32 sival_ptr;
 } sigval_t32;
 
-#endif /* __KERNEL__ */
-
-typedef struct siginfo {
-	int si_signo;
-	int si_errno;
-	int si_code;
-
-	union {
-		int _pad[SI_PAD_SIZE];
-
-		/* kill() */
-		struct {
-			pid_t _pid;		/* sender's pid */
-			uid_t _uid;		/* sender's uid */
-		} _kill;
-
-		/* POSIX.1b timers */
-		struct {
-			unsigned int _timer1;
-			unsigned int _timer2;
-		} _timer;
-
-		/* POSIX.1b signals */
-		struct {
-			pid_t _pid;		/* sender's pid */
-			uid_t _uid;		/* sender's uid */
-			sigval_t _sigval;
-		} _rt;
-
-		/* SIGCHLD */
-		struct {
-			pid_t _pid;		/* which child */
-			uid_t _uid;		/* sender's uid */
-			int _status;		/* exit code */
-			clock_t _utime;
-			clock_t _stime;
-		} _sigchld;
-
-		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
-		struct {
-			void *_addr; /* faulting insn/memory ref. */
-			int  _trapno; /* TRAP # which caused the signal */
-		} _sigfault;
-
-		/* SIGPOLL */
-		struct {
-			long _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
-			int _fd;
-		} _sigpoll;
-	} _sifields;
-} siginfo_t;
-
-#ifdef __KERNEL__
-
 typedef struct siginfo32 {
 	int si_signo;
 	int si_errno;
@@ -126,8 +71,6 @@
 
 #endif /* __KERNEL__ */
 
-#define si_trapno	_sifields._sigfault._trapno
-
 #define SI_NOINFO	32767		/* no information in siginfo_t */
 
 /*
@@ -152,17 +95,6 @@
 	} _sigev_un;
 } sigevent_t32;
 
-#include <linux/string.h>
-
-static inline void copy_siginfo(siginfo_t *to, siginfo_t *from)
-{
-	if (from->si_code < 0)
-		*to = *from;
-	else
-		/* _sigchld is currently the largest know union member */
-		memcpy(to, from, 4*sizeof(int) + sizeof(from->_sifields._sigchld));
-}
-
 extern int copy_siginfo_to_user32(siginfo_t32 *to, siginfo_t *from);
 
 #endif /* __KERNEL__ */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bring sparc{64} into the generic siginfo fold
  2002-10-10  5:42 ` David S. Miller
@ 2002-10-10  6:07   ` Stephen Rothwell
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Rothwell @ 2002-10-10  6:07 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel, anton

Hi Dave,

On Wed, 09 Oct 2002 22:42:32 -0700 (PDT) "David S. Miller" <davem@redhat.com> wrote:
>
>    From: Stephen Rothwell <sfr@canb.auug.org.au>
>    Date: Thu, 10 Oct 2002 15:43:32 +1000
> 
>    This patch (uncompiled, untested) enables sparc and sparc64 to use
>    the gerneic siginfo structure.  Hope you like it :-)
>    
> Thanks I'll have a look :)

This one is on top of the previous one and removes the arch specific
version of copy_siginfo_to_user from sparc and sparc64.

difstat:
 arch/sparc/kernel/signal.c    |   32 --------------------------------
 arch/sparc64/kernel/signal.c  |   32 --------------------------------
 include/asm-sparc/siginfo.h   |    1 -
 include/asm-sparc64/siginfo.h |    1 -
 kernel/signal.c               |    3 +++
 5 files changed, 3 insertions(+), 66 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.41-1.747-si.1/arch/sparc/kernel/signal.c 2.5.41-1.747-si.2/arch/sparc/kernel/signal.c
--- 2.5.41-1.747-si.1/arch/sparc/kernel/signal.c	2002-10-08 12:02:40.000000000 +1000
+++ 2.5.41-1.747-si.2/arch/sparc/kernel/signal.c	2002-10-10 16:00:14.000000000 +1000
@@ -90,38 +90,6 @@
 	__siginfo_fpu_t		fpu_state;
 };
 
-int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from)
-{
-	if (!access_ok(VERIFY_WRITE, to, sizeof(siginfo_t)))
-		return -EFAULT;
-	if (from->si_code < 0)
-		return __copy_to_user(to, from, sizeof(siginfo_t));
-	else {
-		int err;
-
-		/* If you change siginfo_t structure, please be sure
-		   this code is fixed accordingly.
-		   It should never copy any pad contained in the structure
-		   to avoid security leaks, but must copy the generic
-		   3 ints plus the relevant union member.  */
-		err = __put_user(from->si_signo, &to->si_signo);
-		err |= __put_user(from->si_errno, &to->si_errno);
-		err |= __put_user((short)from->si_code, &to->si_code);
-		switch (from->si_code >> 16) {
-		case __SI_CHLD >> 16:
-			err |= __put_user(from->si_utime, &to->si_utime);
-			err |= __put_user(from->si_stime, &to->si_stime);
-		/* case __SI_RT: This is not generated by the kernel as of now.  */
-			err |= __put_user(from->si_status, &to->si_status);
-		default:
-			err |= __put_user(from->si_uid, &to->si_uid);
-			err |= __put_user(from->si_pid, &to->si_pid);
-			break;
-		}
-		return err;
-	}
-}
-
 /* Align macros */
 #define SF_ALIGNEDSZ  (((sizeof(struct signal_sframe) + 7) & (~7)))
 #define NF_ALIGNEDSZ  (((sizeof(struct new_signal_frame) + 7) & (~7)))
diff -ruN 2.5.41-1.747-si.1/arch/sparc64/kernel/signal.c 2.5.41-1.747-si.2/arch/sparc64/kernel/signal.c
--- 2.5.41-1.747-si.1/arch/sparc64/kernel/signal.c	2002-10-08 12:02:40.000000000 +1000
+++ 2.5.41-1.747-si.2/arch/sparc64/kernel/signal.c	2002-10-10 16:03:42.000000000 +1000
@@ -36,38 +36,6 @@
 static int do_signal(sigset_t *oldset, struct pt_regs * regs,
 		     unsigned long orig_o0, int ret_from_syscall);
 
-int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from)
-{
-	if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t)))
-		return -EFAULT;
-	if (from->si_code < 0)
-		return __copy_to_user(to, from, sizeof(siginfo_t));
-	else {
-		int err;
-
-		/* If you change siginfo_t structure, please be sure
-		   this code is fixed accordingly.
-		   It should never copy any pad contained in the structure
-		   to avoid security leaks, but must copy the generic
-		   3 ints plus the relevant union member.  */
-		err = __put_user(*(long *)&from->si_signo, (long *)&to->si_signo);
-		err |= __put_user((short)from->si_code, &to->si_code);
-		switch (from->si_code >> 16) {
-		case __SI_CHLD >> 16:
-			err |= __put_user(from->si_utime, &to->si_utime);
-			err |= __put_user(from->si_stime, &to->si_stime);
-		case __SI_FAULT >> 16:
-		case __SI_POLL >> 16:
-			err |= __put_user(from->si_trapno, &to->si_trapno);
-		default:
-			err |= __put_user(from->si_addr, &to->si_addr);
-			break;
-		/* case __SI_RT: This is not generated by the kernel as of now.  */
-		}
-		return err;
-	}
-}
-
 /* {set, get}context() needed for 64-bit SparcLinux userland. */
 asmlinkage void sparc64_set_context(struct pt_regs *regs)
 {
diff -ruN 2.5.41-1.747-si.1/include/asm-sparc/siginfo.h 2.5.41-1.747-si.2/include/asm-sparc/siginfo.h
--- 2.5.41-1.747-si.1/include/asm-sparc/siginfo.h	2002-10-10 15:17:50.000000000 +1000
+++ 2.5.41-1.747-si.2/include/asm-sparc/siginfo.h	2002-10-10 16:01:26.000000000 +1000
@@ -7,7 +7,6 @@
 
 #define __ARCH_SI_UID_T		unsigned int
 #define __ARCH_SI_TRAPNO
-#define HAVE_ARCH_COPY_SIGINFO_TO_USER
 
 #include <asm-generic/siginfo.h>
 
diff -ruN 2.5.41-1.747-si.1/include/asm-sparc64/siginfo.h 2.5.41-1.747-si.2/include/asm-sparc64/siginfo.h
--- 2.5.41-1.747-si.1/include/asm-sparc64/siginfo.h	2002-10-10 15:29:34.000000000 +1000
+++ 2.5.41-1.747-si.2/include/asm-sparc64/siginfo.h	2002-10-10 16:04:29.000000000 +1000
@@ -8,7 +8,6 @@
 
 #define __ARCH_SI_PREAMBLE_SIZE	(4 * sizeof(int))
 #define __ARCH_SI_TRAPNO
-#define HAVE_ARCH_COPY_SIGINFO_TO_USER
 
 #include <asm-generic/siginfo.h>
 
diff -ruN 2.5.41-1.747-si.1/kernel/signal.c 2.5.41-1.747-si.2/kernel/signal.c
--- 2.5.41-1.747-si.1/kernel/signal.c	2002-10-08 12:03:00.000000000 +1000
+++ 2.5.41-1.747-si.2/kernel/signal.c	2002-10-10 16:01:38.000000000 +1000
@@ -1427,6 +1427,9 @@
 		break;
 	case __SI_FAULT:
 		err |= __put_user(from->si_addr, &to->si_addr);
+#ifdef __ARCH_SI_TRAPNO
+		err |= __put_user(from->si_trapno, &to->si_trapno);
+#endif
 		break;
 	case __SI_CHLD:
 		err |= __put_user(from->si_pid, &to->si_pid);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-10  6:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-10  5:43 [PATCH] bring sparc{64} into the generic siginfo fold Stephen Rothwell
2002-10-10  5:42 ` David S. Miller
2002-10-10  6:07   ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®