Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Oct 2002 02:29:01 -0700 (PDT)
From:      Don Lewis <dl-freebsd@catspoiler.org>
To:        jmallett@FreeBSD.ORG
Cc:        dl-freebsd@catspoiler.org, arch@FreeBSD.ORG
Subject:   Re: [jmallett@FreeBSD.org: [PATCH] Reliable signal queues, etc., [for review]]
Message-ID:  <200210050929.g959T1vU023691@gw.catspoiler.org>
In-Reply-To: <20021005011257.A16980@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On  5 Oct, Juli Mallett wrote:
> * De: Don Lewis <dl-freebsd@catspoiler.org> [ Data: 2002-10-05 ]
> 	[ Subjecte: Re: [jmallett@FreeBSD.org: [PATCH] Reliable signal queues, etc., [for review]] ]
>> On  5 Oct, Juli Mallett wrote:
>> > To
>> > accomodate situations where allocation of a 'ksiginfo' is a failure
>> > mode (no memory), the destination process is told to exit via a new
>> > member of 'struct proc', p_suicide, which tells a process to kill itself
>> > next time it goes through userret.
>> 
>> I hope that doesn't happen when I fg my editor ...
> 
> In this situation (can't allocate 64 bytes) you're screwed if you have an
> editor in the background, coming to the foreground, anyway.

A lot of things that receive SIGCHLD, such as shells and inetd could
also be affected a temporary shortage of kmem.

Somehow it seems wasteful to have to allocate kmem to deliver SIGKILL.

How is an ordinary userland program prevented from consuming all of kmem
by blocking signal delivery and looping on kill()?  Does a quota system
need to be added?

The following code never sets error to anything other than zero.  It
also looks like it is missing a return statement for the malloc() failed
case.

+int
+ksiginfo_alloc(struct ksiginfo **ksip, struct proc *p, int signo)
+{
+	int error;
+	struct ksiginfo *ksi;
+
+	error = 0;
+
+	PROC_LOCK_ASSERT(p, MA_NOTOWNED);
+	ksi = malloc(sizeof *ksi, M_KSIGINFO, M_ZERO | M_NOWAIT);
+	if (ksi == NULL) {
+		PROC_LOCK(p);
+		p->p_suicide = 1;
+		PROC_UNLOCK(p);
+	}
+	ksi->ksi_signo = signo;
+	if (curproc != NULL) {
+		ksi->ksi_pid = curproc->p_pid;
+		ksi->ksi_ruid = curproc->p_ucred->cr_uid;
+	}
+	*ksip = ksi;
+	return (error);
+}







To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210050929.g959T1vU023691>