mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, torvalds@osdl.org, marcelo.tosatti@cyclades.com
Subject: [PATCH 5/11] enforce rlimits on queued signals
Date: Tue, 11 May 2004 01:52:20 -0700	[thread overview]
Message-ID: <20040511015219.D21045@build.pdx.osdl.net> (raw)
In-Reply-To: <20040511015015.C21045@build.pdx.osdl.net>; from chrisw@osdl.org on Tue, May 11, 2004 at 01:50:15AM -0700

Add a user_struct to the sigqueue structure.  Charge sigqueue allocation
and destruction to the user_struct rather than a global pool.  This per
user rlimit accounting obsoletes the global queued_signals accouting.

===== include/linux/signal.h 1.15 vs edited =====
--- 1.15/include/linux/signal.h	Thu Jan 15 12:40:33 2004
+++ edited/include/linux/signal.h	Mon May 10 16:16:13 2004
@@ -19,6 +19,7 @@
 	spinlock_t *lock;
 	int flags;
 	siginfo_t info;
+	struct user_struct *user;
 };
 
 /* flags values. */
===== kernel/signal.c 1.115 vs edited =====
--- 1.115/kernel/signal.c	Mon May 10 03:04:00 2004
+++ edited/kernel/signal.c	Mon May 10 16:16:13 2004
@@ -264,17 +264,19 @@
 	return sig;
 }
 
-struct sigqueue *__sigqueue_alloc(void)
+static struct sigqueue *__sigqueue_alloc(void)
 {
 	struct sigqueue *q = 0;
 
-	if (atomic_read(&nr_queued_signals) < max_queued_signals)
+	if (atomic_read(&current->user->sigpending) < 
+			current->rlim[RLIMIT_SIGPENDING].rlim_cur)
 		q = kmem_cache_alloc(sigqueue_cachep, GFP_ATOMIC);
 	if (q) {
-		atomic_inc(&nr_queued_signals);
 		INIT_LIST_HEAD(&q->list);
 		q->flags = 0;
 		q->lock = 0;
+		q->user = get_uid(current->user);
+		atomic_inc(&q->user->sigpending);
 	}
 	return(q);
 }
@@ -283,8 +285,9 @@
 {
 	if (q->flags & SIGQUEUE_PREALLOC)
 		return;
+	atomic_dec(&q->user->sigpending);
+	free_uid(q->user);
 	kmem_cache_free(sigqueue_cachep, q);
-	atomic_dec(&nr_queued_signals);
 }
 
 static void flush_sigqueue(struct sigpending *queue)
@@ -719,12 +722,14 @@
 	   make sure at least one signal gets delivered and don't
 	   pass on the info struct.  */
 
-	if (atomic_read(&nr_queued_signals) < max_queued_signals)
+	if (atomic_read(&t->user->sigpending) <
+			t->rlim[RLIMIT_SIGPENDING].rlim_cur)
 		q = kmem_cache_alloc(sigqueue_cachep, GFP_ATOMIC);
 
 	if (q) {
-		atomic_inc(&nr_queued_signals);
 		q->flags = 0;
+		q->user = get_uid(t->user);
+		atomic_inc(&q->user->sigpending);
 		list_add_tail(&q->list, &signals->list);
 		switch ((unsigned long) info) {
 		case 0:


  reply	other threads:[~2004-05-11  8:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11  8:42 [PATCH 0/11] rlimits for both queued signals and POSIX mqueues Chris Wright
2004-05-11  8:45 ` [PATCH 1/11] add rlimit entry for controlling queued signals Chris Wright
2004-05-11  8:46   ` [PATCH 2/11] add sigpending field to user_struct Chris Wright
2004-05-11  8:48     ` [PATCH 3/11] pass task_struct in send_signal() Chris Wright
2004-05-11  8:50       ` [PATCH 4/11] add simple get_uid() helper Chris Wright
2004-05-11  8:52         ` Chris Wright [this message]
2004-05-11  8:53           ` [PATCH 6/11] remove unused queued_signals global accounting Chris Wright
2004-05-11  8:56             ` [PATCH 7/11] add rlimit entry for POSIX mqueue allocation Chris Wright
2004-05-11  8:58               ` [PATCH 8/11] add mq_bytes to user_struct Chris Wright
2004-05-11  9:00                 ` [PATCH 9/11] add mq_attr_ok() helper Chris Wright
2004-05-11  9:02                   ` [PATCH 10/11] enforce rlimits for POSIX mqueue allocation Chris Wright
2004-05-11  9:04                     ` [PATCH 11/11] adjust default mqueue sizes Chris Wright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040511015219.D21045@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®