Subject: kern/3379: Exec fails if stack limit is not on page boundary.
To: None <email@example.com>
From: None <firstname.lastname@example.org>
Date: 03/22/1997 15:06:55
>Synopsis: Exec fails if stack limit is not on page boundary.
>Responsible: kern-bug-people (Kernel Bug People)
>Arrival-Date: Fri Mar 21 22:20:02 1997
>Originator: enami tsugutomo
>Release: NetBSD-current 1997 Mar. 20
System: NetBSD plants-doll.enami.ba2.so-net.or.jp 1.2D NetBSD 1.2D (PLANTS_DOLL) #265: Sat Mar 22 14:20:51 JST 1997 email@example.com:/usr/src/sys/arch/i386/compile/PLANTS_DOLL i386
Exec fails if stack limit is not on page boundary.
Following shell script (or any equivalent C/csh/... program) fails.
enami@plants-doll% cat hoge
ulimit -s 513
This is because vm_allocate() for stack area fails.
In the function exec_aout_setup_stack(), it tries to setup two
contiguous regions for stack space without considering page
boundary. But in vm_allocate(), which is called via
vmcmd_map_zero(), start address of region is automatically
truncated to page boundary (but length are left unchanged).
Thus, if boundary of the regions are not on page boundary,
they overlaps and later request of allocate fails.
So, to fix this, adjust boundary of the regions to page
boundary in exec_aout_setup_stack() or make
p->p_rlimit[RLIMIT_STACK].rlim_cur always to fit page boundary
when setting (if maxsaddr and minsaddr are already on page
Note that function exec_ecoff_setup_stack() is very similar to
exec_aout_setup_stack(), so if the latter is needed to be
modified, former also may needed.