Re: grep bug

From: Bruce Evans <bde_at_zeta.org.au>
Date: Tue, 10 Feb 2004 10:18:43 +1100 (EST)
On Mon, 9 Feb 2004, Stefan Farfeleder wrote:

> On Sun, Feb 08, 2004 at 06:36:23PM -0800, Kris Kennaway wrote:
> > kkenn_at_rot13:~ grep -r foo / > /dev/null
> > grep: /dev/network: Permission denied
> > grep: /dev/geom.ctl: Permission denied
> > grep: /dev/devctl: Permission denied
> > grep: /dev/ata: Permission denied
> > grep: /dev/console: Permission denied
> > grep in realloc(): error: allocation failed
> > ^C^C^CAbort (core dumped)
>
> -current aborts by default on memory allocation failures, you have to
> set the 'a' flag via MALLOC_OPTIONS or /etc/malloc.conf.

I have this turned off in /etc/malloc.conf, but turning it off has been
broken for about a year for user root and group wheel:

%%%
Index: malloc.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdlib/malloc.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -2 -r1.72 -r1.73
--- malloc.c	21 Aug 2002 17:11:00 -0000	1.72
+++ malloc.c	23 Jan 2003 21:26:47 -0000	1.73
_at__at_ -10,5 +10,5 _at__at_

 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.72 2002/08/21 17:11:00 phk Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.73 2003/01/23 21:26:47 phk Exp $");

 /*
_at__at_ -465,4 +465,11 _at__at_
 	}
     }
+
+    /*
+     * Sensitive processes, somewhat arbitrarily defined here as setuid,
+     * setgid, root and wheel cannot afford to have malloc mistakes.
+     */
+    if (issetugid() || getuid() == 0 || getgid() == 0)
+	    malloc_abort = 1;

     UTRACE(0, 0, 0);
%%%

This code is executed after parsing MALLOC_OPTIONS etc., so there is no
way to override it.

Bruce
Received on Mon Feb 09 2004 - 14:19:00 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:42 UTC