stackgap removal in linux_socket.c

David P. Reese, Jr. daver at gomerbud.com
Sun Sep 28 00:07:52 PDT 2003


As I understand, stackgap_init() and stackgap_alloc() allow you to store
temporary data below the stack in a userland process.  I would like to make
sure that the following are in fact correct:

   1)  It is much faster to store data in the stackgap when compared to
       using real dynamic storage like MALLOC() because setting up the
       stackgap simply computes an offset in userspace.

   2)  The stackgap can only be used for a *very* temporary scratch space
       because you have no guarantee that a userland process won't trash
       what you are storing in the stackgap between syscalls.

In removing the use of the stackgap in linux_socket.c, I want to make sure
that I don't overlook a subtlety and shoot myself in the foot.

I would reason that anything small like an int could be defined as a local
variable instead of a stackgap variable while using MALLOC()/FREE() for
allocating large structures in the less often traveled code paths.

Why would anyone use the stackgap in the first place?

-- 
   David P. Reese, Jr.                                     daver at xxxxxxxxxxxx
                                               http://www.gomerbud.com/daver/





More information about the Kernel mailing list