NetBSD Problem Report #12846

Received: (qmail 12175 invoked from network); 6 May 2001 00:30:48 -0000
Message-Id: <20010506003141.3D55A7EAE@beowulf.gw.com>
Date: Sat,  5 May 2001 20:31:41 -0400 (EDT)
From: christos@zoulas.com
Reply-To: christos@zoulas.com
To: gnats-bugs@gnats.netbsd.org
Subject: brk(2) limit detection
X-Send-Pr-Version: 3.95

>Number:         12846
>Category:       lib
>Synopsis:       brk(2) succeeds on values that should fail.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 06 00:31:00 +0000 2001
>Closed-Date:    
>Last-Modified:  Tue May 08 07:09:23 +0000 2001
>Originator:     Christos Zoulas
>Release:        2001-05-03
>Organization:
	None yet, but I keep trying
>Environment:

System: NetBSD beowulf.gw.com 1.5V NetBSD 1.5V (GW-GENERIC) #20: Thu May 3 23:22:33 EDT 2001 kim@nix.suominen.org:/net/nix/src-3/NetBSD/cvsroot/src/sys/arch/i386/compile/GW-GENERIC i386
Architecture: i386
Machine: i386
>Description:

Given a large value, brk() succeeds but it should not [i386/sparc at least].
Then things go south.

>How-To-Repeat:
% cat sbrk.c
#include <stdio.h>
#include <unistd.h>

int
main(int argc, char *argv[]) {
	int val = (int)strtoul(argv[1], NULL, 0);
	for (;;) {
		void *p = sbrk(val);
		if (p == (void *) - 1) {
			break;
		}
		printf("%p\n", p);
	}
}
% cat brk.c
#include <stdio.h>
#include <unistd.h>

int
main(int argc, char *argv[]) {
	int val = (int)strtoul(argv[1], NULL, 0);
	void *p = (char *) val;
	printf("brk@ %p\n", p);
	if (brk(p)) {
		err(1, "brk");
	}
	printf("%p\n", p);
}
% ./sbrk 0x01000000
0x8049aa0
0x905b000
0xa05b000
0xb05b000
0xc05b000
0xd05b000
0xe05b000
% ./brk 0xf7f00000
brk@ 0xf7f00000
Segmentation fault
Exit 139

>Fix:
	Unknown
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->lib-bug-people 
Responsible-Changed-By: wiz 
Responsible-Changed-When: Mon May 7 16:51:24 PDT 2001 
Responsible-Changed-Why:  
Not a gnats problem -- reassigned to proper category. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.