From owner-freebsd-current Mon Jan 18 13:35:04 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA15298 for freebsd-current-outgoing; Mon, 18 Jan 1999 13:35:04 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from janus.syracuse.net (janus.syracuse.net [205.232.47.15]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA15285 for ; Mon, 18 Jan 1999 13:35:01 -0800 (PST) (envelope-from green@unixhelp.org) Received: from localhost (green@localhost) by janus.syracuse.net (8.8.8/8.8.7) with ESMTP id QAA23082; Mon, 18 Jan 1999 16:34:49 -0500 (EST) Date: Mon, 18 Jan 1999 16:34:49 -0500 (EST) From: Brian Feldman X-Sender: green@janus.syracuse.net To: Mike Smith cc: Julian Elischer , Matthew Dillon , current@FreeBSD.ORG Subject: Re: kernel malloc and M_CANWAIT In-Reply-To: <199901182105.NAA18722@dingo.cdrom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 18 Jan 1999, Mike Smith wrote: > > > So malloc() will generally not return NULL even in low memory situations > > > unless the KVM map fills up, which isn't supposed to happen but can in > > > certain severe circumstances. Callers should therefore check for NULL. > > > > why not just put it in a loop and block on lbolt? > > (or call panic) > > Because you shouldn't panic unless there's no alternative. Panicking > on resource starvation is just totally lame. And what's wrong with spinning inside malloc until the resources are free? There are places that architecturally require M_WAITOK to not return NULL. Look at the void () functions that call malloc/MALLOC. Also, commit the attached patch; it was OKed by Bruce to disallow this, but he seems to forget to commit it. > > -- > \\ Sometimes you're ahead, \\ Mike Smith > \\ sometimes you're behind. \\ mike@smith.net.au > \\ The race is long, and in the \\ msmith@freebsd.org > \\ end it's only with yourself. \\ msmith@cdrom.com > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > Brian Feldman _ __ ___ ___ ___ green@unixhelp.org _ __ ___ | _ ) __| \ http://www.freebsd.org/ _ __ ___ ____ | _ \__ \ |) | FreeBSD: The Power to Serve! _ __ ___ ____ _____ |___/___/___/ --- src/sys/kern/vfs_syscalls.c.orig Fri Dec 25 22:27:21 1998 +++ src/sys/kern/vfs_syscalls.c Fri Dec 25 22:28:12 1998 @@ -2909,6 +2909,10 @@ if (error = namei(&nd)) return (error); vp = nd.ni_vp; + if (vp->v_type == VFIFO) { + error = EINVAL; + goto out; + } if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) goto out; if (p->p_ucred->cr_uid != vattr.va_uid && To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message