kernel: make sure user text, data and bss wont overlap the stack segment in sysexec()

This commit is contained in:
cinap_lenrek 2013-12-29 06:11:18 +01:00
parent 8cef1794d6
commit afc2d547e1

View file

@ -283,7 +283,7 @@ sysexec(ulong *arg)
text = l2be(exec.text);
entry = l2be(exec.entry);
if(n==sizeof(Exec) && (magic == AOUT_MAGIC)){
if(text >= USTKTOP-UTZERO
if(text >= (USTKTOP-USTKSIZE)-(UTZERO+sizeof(Exec))
|| entry < UTZERO+sizeof(Exec)
|| entry >= UTZERO+sizeof(Exec)+text)
error(Ebadexec);
@ -322,7 +322,7 @@ sysexec(ulong *arg)
d = (t + data + (BY2PG-1)) & ~(BY2PG-1);
bssend = t + data + bss;
b = (bssend + (BY2PG-1)) & ~(BY2PG-1);
if(t >= KZERO || d >= KZERO || b >= KZERO)
if(t >= (USTKTOP-USTKSIZE) || d >= (USTKTOP-USTKSIZE) || b >= (USTKTOP-USTKSIZE))
error(Ebadexec);
/*