From owner-freebsd-arch Mon Oct 7 11:54:41 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3EDCC37B401 for ; Mon, 7 Oct 2002 11:54:39 -0700 (PDT) Received: from mail.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6FDB343E77 for ; Mon, 7 Oct 2002 11:54:38 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 24832 invoked from network); 7 Oct 2002 18:54:38 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail12.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 7 Oct 2002 18:54:38 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.6/8.12.6) with ESMTP id g97Isan5003000; Mon, 7 Oct 2002 14:54:36 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200210050929.g959T1vU023691@gw.catspoiler.org> Date: Mon, 07 Oct 2002 14:54:40 -0400 (EDT) From: John Baldwin To: Don Lewis Subject: Re: [jmallett@FreeBSD.org: [PATCH] Reliable signal queues, etc., Cc: arch@FreeBSD.ORG, jmallett@FreeBSD.ORG Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 05-Oct-2002 Don Lewis wrote: > On 5 Oct, Juli Mallett wrote: >> * De: Don Lewis [ 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; This is not safe w/o proc lock held. Probably should be using curthread and td_ucred instead. Also, curproc cannot be NULL in current. > + } > + *ksip = ksi; > + return (error); > +} > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message