Skip site navigation (1)Skip section navigation (2)
Date:      Mon,  6 Dec 1999 16:40:49 -0500 (EST)
From:      Andrew Gallatin <gallatin@cs.duke.edu>
To:        freebsd-hackers@freebsd.org
Subject:   Is part of user stack always mapped?
Message-ID:  <14412.10798.476867.196687@grasshopper.cs.duke.edu>

next in thread | raw e-mail | index | archive | help


I've been getting the osf1ulator (alpha/osf1 abi ported from NetBSD
over a year ago) on its feet again after this fall's signal changes.
When looking closely at the emulators which are currently in the tree,
I notice that they are they directly dereferencing memory which was
allocated on the user's stack via stackgap_alloc() from within the
kernel.


stackgap_init()
{
#define szsigcode (*(curproc->p_sysent->sv_szsigcode))
        return (caddr_t)(((caddr_t)PS_STRINGS) - szsigcode - SPARE_USRSPACE);
}

static __inline void *
stackgap_alloc(sgp, sz)
        caddr_t *sgp;
        size_t   sz;
{
        void    *p = (void *) *sgp;
        *sgp += ALIGN(sz);
        return p;
}

<...>
                        sigset_t *set;
			caddr_t sg;
			
			sg = stackgap_init();
                        set = stackgap_alloc(&sg, sizeof(sigset_t));
                        *set = p->p_sigmask;
<..>

I was under the impression that this was a no-no & one should use
copyin/copout & friends to access memory on users's stacks.  Although
this appears to work on the i386, if I try this on the alpha I take a
fatal trap when accessing *set.

So -- how does this work on the i386?  Is  the user's stack always
mappeped into the kernel's address space?  Should it also work on the
alpha? 

Apologies for wasting your time if I'm missing something obvious,

------------------------------------------------------------------------------
Andrew Gallatin, Sr Systems Programmer	http://www.cs.duke.edu/~gallatin
Duke University				Email: gallatin@cs.duke.edu
Department of Computer Science		Phone: (919) 660-6590





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




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