[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Probably bad implementation in Pexec()



Lonny Pursell a écrit :
on 11/6/07 7:37 AM, Olivier Landemarre wrote:

Hello

I'm currently looking source code in Mint Pexec (k_exec.c), and for me
there is a trouble in source code

in

exec_region() there is cpushi((void *) b->p_tbase, b->p_tlen);

That is a good idea except it could be wrong or not enough in some cases.
The case is AES (XaAES, MyAES, OAESIS and probably NAES) with the load
of accessory (I think this is a bad implementation of load
of accessory), they change  b->p_tbase to put there own init code so
when exec_region is used the cpushi is not on the code of
accessory but only at is end (XaAES case) or anywhere. The cpushi()
should probably done after load_region() and  by security I think it
should stay in exec_region() too.
But probably the best should not have specific code for accessory, there
is only mother basepage to fill NULL when exec() an accessory.


I'm wrong?

Where is it documented that a desk accessory "change b->p_tbase to put there
own init code"?
Not write but it is done in fact, by all AESs under Mint (look in shel_write() implementation of XaAES (xa_shel.c)), because the basepage of the father should be NULL for accessory, this is the way for accessory to know if they are application or accessory, if you launch an acc as an application, you have most of time an application (ex mintsetter). And this is done like this because before launch the program Mint put the child basepage and there is no way to put to NULL father basepage (look in sys_pexec() )

...
if (mkgo)
	{
		BASEPAGE *b;
		long r = 0;

		/* tell the child who the parent was */
		b = (BASEPAGE *)base->loc;

		if (overlay)
		{
			b->p_parent = get_curproc()->p_mem->base->p_parent;
			p = get_curproc();

			/* make sure that exec_region doesn't free the base and env */
			base->links++;
			env->links++;
		}
		else
		{
			b->p_parent = get_curproc()->p_mem->base;
			p = fork_proc(thread ? (FORK_SHAREVM | FORK_SHAREEXT) : FORK_SHAREEXT, &r);
		}
...

The father basepage is put when it is exec and not when loaded, if it was put when loaded, we could change it before exec it and so
no need change b->p_tbase




Far as I can tell an ACC is a standard gemdos binary.

Near!

Olivier