Subject: kern/11093: mlock() fails for non-root
To: None <gnats-bugs@gnats.netbsd.org>
From: None <is@beverly.kleinbus.org>
List: netbsd-bugs
Date: 09/27/2000 13:22:20
>Number:         11093
>Category:       kern
>Synopsis:       mlock() fails for non-root
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 27 13:28:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Ignatios Souvatzis
>Release:        early September 2000
>Organization:
	myself
>Environment:
	
System: NetBSD marie 1.5_ALPHA2 NetBSD 1.5_ALPHA2 (SHARKGER) #0: Tue Sep 26 23:12:10 CEST 2000 is@marie:/var/obj/kernel/SHARKGER arm32


>Description:
	On arm32/1.5 and i386/1.5 and i386/1.4.2:

	mlock() fails and gets EPERM
		mlock: Operation not permitted
	if called as non-root. As root it is fine.

	It works as advertized on m68k.
>How-To-Repeat:

Test code:

#include <sys/types.h>
#include <sys/mman.h>
#include <sys/errno.h>
#include <err.h>
#include <stdio.h>
#include <unistd.h>

int 
main() {

	int rc;
	int ps;
	size_t sz;
	char *p;
	unsigned u;

	ps = getpagesize();
	p = malloc(ps);
	printf("address = 0x%x, size = %d\n", (unsigned)p, ps);

	rc = mlock(p , ps);
	if (rc)
		perror("mlock");
	(void)getchar();
}

% cc -o test test.c
./test
% ./test
address = 0x5000, size = 4096
mlock: Operation not permitted

% su
# ./test
address = 0x5000, size = 4096
# 

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted: