[RFC PATCH] New SA_NOPRNOTIF sigaction flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sometimes when a task is being ptraced (e.g. by a debugger), one would
like to handle a certain signal (e.g. SIGSEGV) within the task without
having to notify the ptracing task.

An example of this is if one would like to detect the rate at which pages
are being modified, and therefore mprotect() the pages. The SIGSEGV
handler just keeps track of how many writes are happening on each of the
mprotect()ed pages, but you don't want to bother the debugger with these
SIGSEGVs.

I'm proposing the addition of a new SA_NOPRNOTIF flag to struct sigaction
{ sa_flags }, which makes the kernel skip notifying the ptracing parent if
the flag is set for a sighandler for a particular signal.

This trivial patch achieves just that.

Comments?

Thanks

- Bhavesh

ps: wonder why POSIX, SUSV3, SVR4, etc. didn't have this option. Seems
like a handy flag to have...


Bhavesh P. Davda | Distinguished Member of Technical Staff | Avaya |
1300 West 120th Avenue | B3-B03 | Westminster, CO 80234 | U.S.A. |
Voice/Fax: 303.538.4438 | [email protected]
diff --git a/include/asm-alpha/signal.h b/include/asm-alpha/signal.h
--- a/include/asm-alpha/signal.h
+++ b/include/asm-alpha/signal.h
@@ -99,6 +99,10 @@ typedef unsigned long sigset_t;
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_NOMASK	SA_NODEFER
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 /* 
  * sigaltstack controls
diff --git a/include/asm-arm/signal.h b/include/asm-arm/signal.h
--- a/include/asm-arm/signal.h
+++ b/include/asm-arm/signal.h
@@ -102,6 +102,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 
 /* 
diff --git a/include/asm-arm26/signal.h b/include/asm-arm26/signal.h
--- a/include/asm-arm26/signal.h
+++ b/include/asm-arm26/signal.h
@@ -102,6 +102,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 
 /* 
diff --git a/include/asm-cris/signal.h b/include/asm-cris/signal.h
--- a/include/asm-cris/signal.h
+++ b/include/asm-cris/signal.h
@@ -96,6 +96,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-frv/signal.h b/include/asm-frv/signal.h
--- a/include/asm-frv/signal.h
+++ b/include/asm-frv/signal.h
@@ -95,6 +95,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-h8300/signal.h b/include/asm-h8300/signal.h
--- a/include/asm-h8300/signal.h
+++ b/include/asm-h8300/signal.h
@@ -95,6 +95,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-i386/signal.h b/include/asm-i386/signal.h
--- a/include/asm-i386/signal.h
+++ b/include/asm-i386/signal.h
@@ -98,6 +98,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-ia64/signal.h b/include/asm-ia64/signal.h
--- a/include/asm-ia64/signal.h
+++ b/include/asm-ia64/signal.h
@@ -77,6 +77,10 @@
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-m32r/signal.h b/include/asm-m32r/signal.h
--- a/include/asm-m32r/signal.h
+++ b/include/asm-m32r/signal.h
@@ -102,6 +102,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-m68k/signal.h b/include/asm-m68k/signal.h
--- a/include/asm-m68k/signal.h
+++ b/include/asm-m68k/signal.h
@@ -95,6 +95,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 /*
  * sigaltstack controls
diff --git a/include/asm-m68knommu/signal.h b/include/asm-m68knommu/signal.h
--- a/include/asm-m68knommu/signal.h
+++ b/include/asm-m68knommu/signal.h
@@ -95,6 +95,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 /* 
  * sigaltstack controls
diff --git a/include/asm-mips/signal.h b/include/asm-mips/signal.h
--- a/include/asm-mips/signal.h
+++ b/include/asm-mips/signal.h
@@ -86,6 +86,10 @@ typedef unsigned long old_sigset_t;		/* 
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000	/* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000	/* Only for o32 */
 
diff --git a/include/asm-parisc/signal.h b/include/asm-parisc/signal.h
--- a/include/asm-parisc/signal.h
+++ b/include/asm-parisc/signal.h
@@ -70,6 +70,10 @@
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000 /* obsolete -- ignored */
 
diff --git a/include/asm-ppc/signal.h b/include/asm-ppc/signal.h
--- a/include/asm-ppc/signal.h
+++ b/include/asm-ppc/signal.h
@@ -88,6 +88,10 @@ typedef struct {
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-ppc64/signal.h b/include/asm-ppc64/signal.h
--- a/include/asm-ppc64/signal.h
+++ b/include/asm-ppc64/signal.h
@@ -85,6 +85,10 @@ typedef struct {
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000u /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000u
 
diff --git a/include/asm-s390/signal.h b/include/asm-s390/signal.h
--- a/include/asm-s390/signal.h
+++ b/include/asm-s390/signal.h
@@ -105,6 +105,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK       SA_NODEFER
 #define SA_ONESHOT      SA_RESETHAND
 #define SA_INTERRUPT    0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER     0x04000000
 
diff --git a/include/asm-sh/signal.h b/include/asm-sh/signal.h
--- a/include/asm-sh/signal.h
+++ b/include/asm-sh/signal.h
@@ -96,6 +96,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-sh64/signal.h b/include/asm-sh64/signal.h
--- a/include/asm-sh64/signal.h
+++ b/include/asm-sh64/signal.h
@@ -95,6 +95,10 @@ typedef struct {
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h
--- a/include/asm-sparc/signal.h
+++ b/include/asm-sparc/signal.h
@@ -142,6 +142,10 @@ struct sigstack {
 #define SA_RESTART	_SV_INTR
 #define SA_ONESHOT	_SV_RESET
 #define SA_INTERRUPT	0x10u
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 #define SA_NOMASK	0x20u
 #define SA_NOCLDWAIT	0x100u
 #define SA_SIGINFO	0x200u
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
--- a/include/asm-sparc64/signal.h
+++ b/include/asm-sparc64/signal.h
@@ -144,6 +144,10 @@ struct sigstack {
 #define SA_RESTART	_SV_INTR
 #define SA_ONESHOT	_SV_RESET
 #define SA_INTERRUPT	0x10u
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 #define SA_NOMASK	0x20u
 #define SA_NOCLDWAIT    0x100u
 #define SA_SIGINFO      0x200u
diff --git a/include/asm-v850/signal.h b/include/asm-v850/signal.h
--- a/include/asm-v850/signal.h
+++ b/include/asm-v850/signal.h
@@ -98,6 +98,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-x86_64/signal.h b/include/asm-x86_64/signal.h
--- a/include/asm-x86_64/signal.h
+++ b/include/asm-x86_64/signal.h
@@ -104,6 +104,10 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/include/asm-xtensa/signal.h b/include/asm-xtensa/signal.h
--- a/include/asm-xtensa/signal.h
+++ b/include/asm-xtensa/signal.h
@@ -96,6 +96,10 @@ typedef struct {
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
+/*
+ * Let's reuse SA_INTERRUPT since it is unused anymore
+ */
+#define SA_NOPRNOTIF	SA_INTERRUPT
 
 #define SA_RESTORER	0x04000000
 
diff --git a/kernel/signal.c b/kernel/signal.c
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1849,7 +1849,11 @@ relock:
 		if (!signr)
 			break; /* will return 0 */
 
-		if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
+		ka = &current->sighand->action[signr-1];
+
+		if ((current->ptrace & PT_PTRACED) && (signr != SIGKILL)
+		    && !(ka->sa.sa_flags & SA_NOPRNOTIF))
+		{
 			ptrace_signal_deliver(regs, cookie);
 
 			/* Let the debugger run.  */

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux