[PATCH and bugfix] Re: POSIX Signals from dynamic to static-Why?

Stephen C. Tweedie (sct@redhat.com)
Mon, 12 Oct 1998 15:37:04 +0100


Hi,

On Fri, 09 Oct 1998 09:59:53 -0500, Steven Suson
<suson@tti.TuckerEnergy.com> said:

> It seems that at some point between 2.1.98 and 2.1.123, the queue
> used for POSIX signals went from a purely dynamic model (limited by
> memory considerations) to a static model (currently 1024). I would very
> much like to know why?

Because queued signals take up privileged, unswappable kernel memory,
and if you don't limit them, then any user can allocate unbounded memory
by sending blocked signals. It's a very effective denial-of-service
attack!

> what about the possibility of reverting to the dynamic model? If this
> isn't feasible, is it possible to increase the limit from 1024, and if
> so, what would be the maximum?

You should be able to set it to any level you want. The patch below
makes both the current number of queued signals and the upper limit
available through the sysctl and /proc/sys/kernel interfaces, and allows
you to modify the limit.

Linus, this also fixes a bug introduced in 2.1.124: somebody renumbered
two of the existing sysctl tables _again_...

--Stephen

----------------------------------------------------------------
--- include/linux/sysctl.h~ Mon Oct 12 13:23:39 1998
+++ include/linux/sysctl.h Mon Oct 12 15:21:26 1998
@@ -83,9 +83,11 @@
KERN_PPC_HTABRECLAIM, /* turn htab reclaimation on/off on PPC */
KERN_PPC_ZEROPAGED, /* turn idle page zeroing on/off on PPC */
KERN_PPC_POWERSAVE_NAP, /* use nap mode for power saving */
- KERN_PPC_L2CR, /* l2cr register on PPC */
KERN_MODPROBE,
-/*29*/ KERN_SG_BIG_BUFF
+ KERN_SG_BIG_BUFF,
+/*30*/ KERN_RTSIGNR, /* Number of queued posix realtime signals */
+ KERN_RTSIGMAX, /* Max allowed number of rt signals */
+/*32*/ KERN_PPC_L2CR, /* l2cr register on PPC */
};


@@ -132,6 +134,7 @@
NET_CORE_RMEM_MAX,
NET_CORE_WMEM_DEFAULT,
NET_CORE_RMEM_DEFAULT,
+ NET_CORE_DESTROY_DELAY, /* Obsolete */
NET_CORE_MAX_BACKLOG,
NET_CORE_FASTROUTE,
NET_CORE_MSG_COST,
--- kernel/signal.c~ Mon Sep 28 12:12:02 1998
+++ kernel/signal.c Mon Oct 12 15:17:12 1998
@@ -36,8 +36,8 @@

static kmem_cache_t *signal_queue_cachep;

-static int nr_queued_signals;
-static int max_queued_signals = 1024;
+int nr_queued_signals;
+int max_queued_signals = 1024;

void __init signals_init(void)
{
--- kernel/sysctl.c~ Mon Oct 12 13:23:39 1998
+++ kernel/sysctl.c Mon Oct 12 15:21:47 1998
@@ -42,6 +42,8 @@
extern int bdf_prm[], bdflush_min[], bdflush_max[];
extern char binfmt_java_interpreter[], binfmt_java_appletviewer[];
extern int sysctl_overcommit_memory;
+extern int nr_queued_signals, max_queued_signals;
+
#ifdef CONFIG_KMOD
extern char modprobe_path[];
#endif
@@ -193,6 +195,10 @@
{KERN_SG_BIG_BUFF, "sg-big-buff", &sg_big_buff, sizeof (int),
0444, NULL, &proc_dointvec},
#endif
+ {KERN_RTSIGNR, "rtsig-nr", &nr_queued_signals, sizeof(int),
+ 0444, NULL, &proc_dointvec},
+ {KERN_RTSIGMAX, "rtsig-max", &max_queued_signals, sizeof(int),
+ 0644, NULL, &proc_dointvec},
{0}
};

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/