Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Aug 2002 14:14:13 -0400
From:      Jake Burkholder <jake@locore.ca>
To:        Ian Dowse <iedowse@maths.tcd.ie>
Cc:        Bruce Evans <bde@zeta.org.au>, arch@FreeBSD.ORG
Subject:   Re: Solving the stack gap issue
Message-ID:  <20020818141413.E590@locore.ca>
In-Reply-To: <200208181751.aa29455@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Sun, Aug 18, 2002 at 05:51:49PM %2B0100
References:  <20020818055951.N12475-100000@gamplex.bde.org> <200208181751.aa29455@salmon.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help
Apparently, On Sun, Aug 18, 2002 at 05:51:49PM +0100,
	Ian Dowse said words to the effect of;

> In message <20020818055951.N12475-100000@gamplex.bde.org>, Bruce Evans writes:
> >enough compat code).  Some compat code doesn't know this very well and
> >causes panics by accessing the stack gap directly.  Non-broken code
> >would require lots more copyins and copyouts to avoid direct accesses:
> 
> Yes, I noticed a lot of places where the Linux emulation code was
> accessing stack gap data without using copyin/copyout. Is there a
> disabled check for this somewhere in the vm_fault code? I seem to
> remember it being discussed somewhere but I can't find any references
> in the code.

Its in trap_pfault; i386 allows faults on any user address in kernel
mode without using copyin/out, alpha allows faults on the stack gap.
I think there's more code that does this, possibly in the i386 floating
point emulation.  Accessing user memory directly from kernel mode only
works on architectures where both are in the same address space, so
this doesn't work at all on sparc64, don't know about others.

> 
> >> 	open(struct thread *td, struct open_args *uap)
> >
> >I would prefer this to be named something like xxx_open() and in a
> >translation layer between Xsyscall() and open(), with the translation
> >layer as null as possible.
> 
> >> 	int sys_open(struct thread *td, char *path, enum uio_seg pathseg,
> >> 	    int flags, int mode);
> >
> >I would prefer this to be named open() and take the same args as open(2).
> >Passing around td args seems to just lead to pessimizations and bugs,
> >since syscalls especially almost require td == curthread to work...
> 
> The only issue with naming things this way is that all other callers
> of the system call (mainly other compat modules) need to be changed
> one way or another at the same time. I just did it this way so that
> syscalls could be changed over one at a time without touching their
> callers for now.
> 
> If there is agreement on the td vs. curthread issue, then that would
> obviously be easy to change. Note that many system calls are not
> as simple as open(2), so having the same arguments for the user and
> kernel versions is not always practical. For example when there is
> a combination of user-supplied structures and buffers, the overhead
> of copying everything into the kernel by the compat module would
> be too high. For *ctl() sysctls, it may require duplicating much
> of the logic of the kernel syscall in the wrapper. A copyin/copyout
> function that takes a UIO_*SPACE argument might help.

There's copyinfrom and copyinstrfrom, copyoutto would probably be useful
as well.

Jake

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020818141413.E590>