From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <6c7727bd06577062ffdbadcef28e33bf@rei2.9hal> Date: Fri, 15 Mar 2013 21:35:49 +0100 From: cinap_lenrek@gmx.de To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] exec() question Topicbox-Message-UUID: 2af739f0-ead8-11e9-9d60-3106f5b1d025 i think you are right. the temporary tstk segment will be before the stack segment like: | txt | dat | bss ... | *unmapedspace* | tstk | stk | the segattach syscall only makes sure you dont map something after or overlapping with the stack. so i think you could indeed map something there and make the front fall off after exec(). you could map a readonly segment there and make the kernel crash when it tries prepare the new stack. segattach() also would try to allocate below the lowest possible stack address when you pass 0 as the address. maybe the tstk (ESEG) should be placed *after* the stack swaping tstk and stk like: #define TSTKTOP (VMAP-BY2PG) #define TSTKSIZ 100 #define USTKTOP (TSTKTOP-TSTKSIZ) #define USTKSIZE (16*1024*1024) but maybe just making the checks in segattach take the tstk into account is simpler... -- cinap