root/fs/exec.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. core_dump
  2. sys_uselib
  3. create_tables
  4. count
  5. copy_strings
  6. change_ldt
  7. read_omagic
  8. do_execve

   1 /*
   2  *  linux/fs/exec.c
   3  *
   4  *  Copyright (C) 1991, 1992  Linus Torvalds
   5  */
   6 
   7 /*
   8  * #!-checking implemented by tytso.
   9  */
  10 
  11 /*
  12  * Demand-loading implemented 01.12.91 - no need to read anything but
  13  * the header into memory. The inode of the executable is put into
  14  * "current->executable", and page faults do the actual loading. Clean.
  15  *
  16  * Once more I can proudly say that linux stood up to being changed: it
  17  * was less than 2 hours work to get demand-loading completely implemented.
  18  */
  19 
  20 #include <linux/fs.h>
  21 #include <linux/sched.h>
  22 #include <linux/kernel.h>
  23 #include <linux/mm.h>
  24 #include <linux/a.out.h>
  25 #include <linux/errno.h>
  26 #include <linux/signal.h>
  27 #include <linux/string.h>
  28 #include <linux/stat.h>
  29 #include <linux/fcntl.h>
  30 #include <linux/ptrace.h>
  31 #include <linux/user.h>
  32 
  33 #include <asm/segment.h>
  34 
  35 extern int sys_exit(int exit_code);
  36 extern int sys_close(int fd);
  37 
  38 /*
  39  * MAX_ARG_PAGES defines the number of pages allocated for arguments
  40  * and envelope for the new program. 32 should suffice, this gives
  41  * a maximum env+arg of 128kB !
  42  */
  43 #define MAX_ARG_PAGES 32
  44 
  45 /*
  46  * These are the only things you should do on a core-file: use only these
  47  * macros to write out all the necessary info.
  48  */
  49 #define DUMP_WRITE(addr,nr) \
  50 while (file.f_op->write(inode,&file,(char *)(addr),(nr)) != (nr)) goto close_coredump
  51 
  52 #define DUMP_SEEK(offset) \
  53 if (file.f_op->lseek) { \
  54         if (file.f_op->lseek(inode,&file,(offset),0) != (offset)) \
  55                 goto close_coredump; \
  56 } else file.f_pos = (offset)            
  57 
  58 /*
  59  * Routine writes a core dump image in the current directory.
  60  * Currently only a stub-function.
  61  *
  62  * Note that setuid/setgid files won't make a core-dump if the uid/gid
  63  * changed due to the set[u|g]id. It's enforced by the "current->dumpable"
  64  * field, which also makes sure the core-dumps won't be recursive if the
  65  * dumping of the process results in another error..
  66  */
  67 int core_dump(long signr, struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
  68 {
  69         struct inode * inode = NULL;
  70         struct file file;
  71         unsigned short fs;
  72         int has_dumped = 0;
  73         register int dump_start, dump_size;
  74         struct user dump;
  75 
  76         if (!current->dumpable)
  77                 return 0;
  78         current->dumpable = 0;
  79 /* See if we have enough room to write the upage.  */
  80         if(current->rlim[RLIMIT_CORE].rlim_cur < PAGE_SIZE/1024) return 0;
  81         __asm__("mov %%fs,%0":"=r" (fs));
  82         __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x10));
  83         if (open_namei("core",O_CREAT | O_WRONLY | O_TRUNC,0600,&inode,NULL)) {
  84                 inode = NULL;
  85                 goto end_coredump;
  86         }
  87         if (!S_ISREG(inode->i_mode))
  88                 goto end_coredump;
  89         if (!inode->i_op || !inode->i_op->default_file_ops)
  90                 goto end_coredump;
  91         file.f_mode = 3;
  92         file.f_flags = 0;
  93         file.f_count = 1;
  94         file.f_inode = inode;
  95         file.f_pos = 0;
  96         file.f_reada = 0;
  97         file.f_op = inode->i_op->default_file_ops;
  98         if (file.f_op->open)
  99                 if (file.f_op->open(inode,&file))
 100                         goto end_coredump;
 101         if (!file.f_op->write)
 102                 goto close_coredump;
 103         has_dumped = 1;
 104 /* changed the size calculations - should hopefully work better. lbt */
 105         dump.magic = CMAGIC;
 106         dump.start_code = 0;
 107         dump.start_stack = regs->esp & ~(PAGE_SIZE - 1);
 108         dump.u_tsize = ((unsigned long) current->end_code) >> 12;
 109         dump.u_dsize = ((unsigned long) (current->brk + (PAGE_SIZE-1))) >> 12;
 110         dump.u_dsize -= dump.u_tsize;
 111         dump.u_ssize = 0;
 112         if (dump.start_stack < TASK_SIZE)
 113                 dump.u_ssize = ((unsigned long) (TASK_SIZE - dump.start_stack)) >> 12;
 114 /* If the size of the dump file exceeds the rlimit, then see what would happen
 115    if we wrote the stack, but not the data area.  */
 116         if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE/1024 >
 117             current->rlim[RLIMIT_CORE].rlim_cur)
 118                 dump.u_dsize = 0;
 119 /* Make sure we have enough room to write the stack and data areas. */
 120         if ((dump.u_ssize+1) * PAGE_SIZE / 1024 >
 121             current->rlim[RLIMIT_CORE].rlim_cur)
 122                 dump.u_ssize = 0;
 123         dump.u_comm = 0;
 124         dump.u_ar0 = (struct pt_regs *)(((int)(&dump.regs)) -((int)(&dump)));
 125         dump.signal = signr;
 126         dump.regs = *regs;
 127 /* Flag indicating the math stuff is valid. We don't support this for the
 128    soft-float routines yet */
 129         if (hard_math) {
 130                 if (dump.u_fpvalid = current->used_math) {
 131                         if (last_task_used_math == current)
 132                                 __asm__("clts ; fnsave %0"::"m" (dump.i387));
 133                         else
 134                                 memcpy(&dump.i387,&current->tss.i387.hard,sizeof(dump.i387));
 135                 }
 136         } else {
 137                 /* we should dump the emulator state here, but we need to
 138                    convert it into standard 387 format first.. */
 139                 dump.u_fpvalid = 0;
 140         }
 141         __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x10));
 142         DUMP_WRITE(&dump,sizeof(dump));
 143         DUMP_SEEK(sizeof(dump));
 144  /* Dump the task struct.  Not be used by gdb, but could be useful */
 145         DUMP_WRITE(current,sizeof(*current));
 146 /* Now dump all of the user data.  Include malloced stuff as well */
 147         DUMP_SEEK(PAGE_SIZE);
 148 /* now we start writing out the user space info */
 149         __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x17));
 150 /* Dump the data area */
 151         if (dump.u_dsize != 0) {
 152                 dump_start = dump.u_tsize << 12;
 153                 dump_size = dump.u_dsize << 12;
 154                 DUMP_WRITE(dump_start,dump_size);
 155         };
 156 /* Now prepare to dump the stack area */
 157         if (dump.u_ssize != 0) {
 158                 dump_start = dump.start_stack;
 159                 dump_size = dump.u_ssize << 12;
 160                 DUMP_WRITE(dump_start,dump_size);
 161         };
 162 close_coredump:
 163         if (file.f_op->release)
 164                 file.f_op->release(inode,&file);
 165 end_coredump:
 166         __asm__("mov %0,%%fs"::"r" (fs));
 167         iput(inode);
 168         return has_dumped;
 169 }
 170 
 171 /*
 172  * Note that a shared library must be both readable and executable due to
 173  * security reasons.
 174  *
 175  * Also note that we take the address to load from from the file itself.
 176  */
 177 int sys_uselib(const char * library)
     /* [previous][next][first][last][top][bottom][index][help] */
 178 {
 179 #define libnum  (current->numlibraries)
 180         struct inode * inode;
 181         struct buffer_head * bh;
 182         struct exec ex;
 183         int error;
 184 
 185         if (!library || get_limit(0x17) != TASK_SIZE)
 186                 return -EINVAL;
 187         if ((libnum >= MAX_SHARED_LIBS) || (libnum < 0))
 188                 return -EINVAL;
 189         error = namei(library,&inode);
 190         if (error)
 191                 return error;
 192         if (!inode->i_sb || !S_ISREG(inode->i_mode) || !permission(inode,MAY_READ)) {
 193                 iput(inode);
 194                 return -EACCES;
 195         }
 196         if (!(bh = bread(inode->i_dev,bmap(inode,0),inode->i_sb->s_blocksize))) {
 197                 iput(inode);
 198                 return -EACCES;
 199         }
 200         if (!IS_RDONLY(inode)) {
 201                 inode->i_atime = CURRENT_TIME;
 202                 inode->i_dirt = 1;
 203         }
 204         ex = *(struct exec *) bh->b_data;
 205         brelse(bh);
 206         if (N_MAGIC(ex) != ZMAGIC || ex.a_trsize || ex.a_drsize ||
 207                 ex.a_text+ex.a_data+ex.a_bss>0x3000000 ||
 208                 inode->i_size < ex.a_text+ex.a_data+ex.a_syms+N_TXTOFF(ex)) {
 209                 iput(inode);
 210                 return -ENOEXEC;
 211         }
 212         current->libraries[libnum].library = inode;
 213         current->libraries[libnum].start = ex.a_entry;
 214         current->libraries[libnum].length = (ex.a_data+ex.a_text+0xfff) & 0xfffff000;
 215         current->libraries[libnum].bss = (ex.a_bss+0xfff) & 0xfffff000;
 216 #if 0
 217         printk("Loaded library %d at %08x, length %08x\n",
 218                 libnum,
 219                 current->libraries[libnum].start,
 220                 current->libraries[libnum].length);
 221 #endif
 222         libnum++;
 223         return 0;
 224 #undef libnum
 225 }
 226 
 227 /*
 228  * create_tables() parses the env- and arg-strings in new user
 229  * memory and creates the pointer tables from them, and puts their
 230  * addresses on the "stack", returning the new stack pointer value.
 231  */
 232 static unsigned long * create_tables(char * p,int argc,int envc)
     /* [previous][next][first][last][top][bottom][index][help] */
 233 {
 234         unsigned long *argv,*envp;
 235         unsigned long * sp;
 236 
 237         sp = (unsigned long *) (0xfffffffc & (unsigned long) p);
 238         sp -= envc+1;
 239         envp = sp;
 240         sp -= argc+1;
 241         argv = sp;
 242         put_fs_long((unsigned long)envp,--sp);
 243         put_fs_long((unsigned long)argv,--sp);
 244         put_fs_long((unsigned long)argc,--sp);
 245         while (argc-->0) {
 246                 put_fs_long((unsigned long) p,argv++);
 247                 while (get_fs_byte(p++)) /* nothing */ ;
 248         }
 249         put_fs_long(0,argv);
 250         while (envc-->0) {
 251                 put_fs_long((unsigned long) p,envp++);
 252                 while (get_fs_byte(p++)) /* nothing */ ;
 253         }
 254         put_fs_long(0,envp);
 255         return sp;
 256 }
 257 
 258 /*
 259  * count() counts the number of arguments/envelopes
 260  */
 261 static int count(char ** argv)
     /* [previous][next][first][last][top][bottom][index][help] */
 262 {
 263         int i=0;
 264         char ** tmp;
 265 
 266         if (tmp = argv)
 267                 while (get_fs_long((unsigned long *) (tmp++)))
 268                         i++;
 269 
 270         return i;
 271 }
 272 
 273 /*
 274  * 'copy_string()' copies argument/envelope strings from user
 275  * memory to free pages in kernel mem. These are in a format ready
 276  * to be put directly into the top of new user memory.
 277  *
 278  * Modified by TYT, 11/24/91 to add the from_kmem argument, which specifies
 279  * whether the string and the string array are from user or kernel segments:
 280  * 
 281  * from_kmem     argv *        argv **
 282  *    0          user space    user space
 283  *    1          kernel space  user space
 284  *    2          kernel space  kernel space
 285  * 
 286  * We do this by playing games with the fs segment register.  Since it
 287  * it is expensive to load a segment register, we try to avoid calling
 288  * set_fs() unless we absolutely have to.
 289  */
 290 static unsigned long copy_strings(int argc,char ** argv,unsigned long *page,
     /* [previous][next][first][last][top][bottom][index][help] */
 291                 unsigned long p, int from_kmem)
 292 {
 293         char *tmp, *pag = NULL;
 294         int len, offset = 0;
 295         unsigned long old_fs, new_fs;
 296 
 297         if (!p)
 298                 return 0;       /* bullet-proofing */
 299         new_fs = get_ds();
 300         old_fs = get_fs();
 301         if (from_kmem==2)
 302                 set_fs(new_fs);
 303         while (argc-- > 0) {
 304                 if (from_kmem == 1)
 305                         set_fs(new_fs);
 306                 if (!(tmp = (char *)get_fs_long(((unsigned long *)argv)+argc)))
 307                         panic("argc is wrong");
 308                 if (from_kmem == 1)
 309                         set_fs(old_fs);
 310                 len=0;          /* remember zero-padding */
 311                 do {
 312                         len++;
 313                 } while (get_fs_byte(tmp++));
 314                 if (p < len) {  /* this shouldn't happen - 128kB */
 315                         set_fs(old_fs);
 316                         return 0;
 317                 }
 318                 while (len) {
 319                         --p; --tmp; --len;
 320                         if (--offset < 0) {
 321                                 offset = p % PAGE_SIZE;
 322                                 if (from_kmem==2)
 323                                         set_fs(old_fs);
 324                                 if (!(pag = (char *) page[p/PAGE_SIZE]) &&
 325                                     !(pag = (char *) page[p/PAGE_SIZE] =
 326                                       (unsigned long *) get_free_page(GFP_USER))) 
 327                                         return 0;
 328                                 if (from_kmem==2)
 329                                         set_fs(new_fs);
 330 
 331                         }
 332                         *(pag + offset) = get_fs_byte(tmp);
 333                 }
 334         }
 335         if (from_kmem==2)
 336                 set_fs(old_fs);
 337         return p;
 338 }
 339 
 340 static unsigned long change_ldt(unsigned long text_size,unsigned long * page)
     /* [previous][next][first][last][top][bottom][index][help] */
 341 {
 342         unsigned long code_limit,data_limit,code_base,data_base;
 343         int i;
 344 
 345         code_limit = TASK_SIZE;
 346         data_limit = TASK_SIZE;
 347         code_base = data_base = 0;
 348         current->start_code = code_base;
 349         set_base(current->ldt[1],code_base);
 350         set_limit(current->ldt[1],code_limit);
 351         set_base(current->ldt[2],data_base);
 352         set_limit(current->ldt[2],data_limit);
 353 /* make sure fs points to the NEW data segment */
 354         __asm__("pushl $0x17\n\tpop %%fs"::);
 355         data_base += data_limit;
 356         for (i=MAX_ARG_PAGES-1 ; i>=0 ; i--) {
 357                 data_base -= PAGE_SIZE;
 358                 if (page[i])
 359                         put_dirty_page(current,page[i],data_base);
 360         }
 361         return data_limit;
 362 }
 363 
 364 static void read_omagic(struct inode *inode, int bytes)
     /* [previous][next][first][last][top][bottom][index][help] */
 365 {
 366         struct buffer_head *bh;
 367         int n, blkno, blk = 0;
 368         char *dest = (char *) 0;
 369         unsigned int block_size;
 370 
 371         block_size = 1024;
 372         if (inode->i_sb)
 373                 block_size = inode->i_sb->s_blocksize;
 374         while (bytes > 0) {
 375                 if (!(blkno = bmap(inode, blk)))
 376                         sys_exit(-1);
 377                 if (!(bh = bread(inode->i_dev, blkno, block_size)))
 378                         sys_exit(-1);
 379                 n = (blk ? block_size : block_size - sizeof(struct exec));
 380                 if (bytes < n)
 381                         n = bytes;
 382 
 383                 memcpy_tofs(dest, (blk ? bh->b_data :
 384                                 bh->b_data + sizeof(struct exec)), n);
 385                 brelse(bh);
 386                 ++blk;
 387                 dest += n;
 388                 bytes -= n;
 389         }
 390         iput(inode);
 391         current->executable = NULL;
 392 }
 393 
 394 /*
 395  * 'do_execve()' executes a new program.
 396  *
 397  * NOTE! We leave 4MB free at the top of the data-area for a loadable
 398  * library.
 399  */
 400 int do_execve(unsigned long * eip,long tmp,char * filename,
     /* [previous][next][first][last][top][bottom][index][help] */
 401         char ** argv, char ** envp)
 402 {
 403         struct inode * inode;
 404         struct buffer_head * bh;
 405         struct exec ex;
 406         unsigned long page[MAX_ARG_PAGES];
 407         int i,argc,envc;
 408         int e_uid, e_gid;
 409         int retval;
 410         int sh_bang = 0;
 411         unsigned long p=PAGE_SIZE*MAX_ARG_PAGES-4;
 412         int ch;
 413 
 414         if ((0xffff & eip[1]) != 0x000f)
 415                 panic("execve called from supervisor mode");
 416         for (i=0 ; i<MAX_ARG_PAGES ; i++)       /* clear page-table */
 417                 page[i]=0;
 418         retval = namei(filename,&inode);        /* get executable inode */
 419         if (retval)
 420                 return retval;
 421         argc = count(argv);
 422         envc = count(envp);
 423         
 424 restart_interp:
 425         if (!S_ISREG(inode->i_mode)) {  /* must be regular file */
 426                 retval = -EACCES;
 427                 goto exec_error2;
 428         }
 429         if (IS_NOEXEC(inode)) {         /* FS mustn't be mounted noexec */
 430                 retval = -EPERM;
 431                 goto exec_error2;
 432         }
 433         if (!inode->i_sb) {
 434                 retval = -EACCES;
 435                 goto exec_error2;
 436         }
 437         i = inode->i_mode;
 438         if (IS_NOSUID(inode) && (((i & S_ISUID) && inode->i_uid != current->
 439             euid) || ((i & S_ISGID) && inode->i_gid != current->egid)) &&
 440             !suser()) {
 441                 retval = -EPERM;
 442                 goto exec_error2;
 443         }
 444         /* make sure we don't let suid, sgid files be ptraced. */
 445         if (current->flags & PF_PTRACED) {
 446                 e_uid = current->euid;
 447                 e_gid = current->egid;
 448         } else {
 449                 e_uid = (i & S_ISUID) ? inode->i_uid : current->euid;
 450                 e_gid = (i & S_ISGID) ? inode->i_gid : current->egid;
 451         }
 452         if (current->euid == inode->i_uid)
 453                 i >>= 6;
 454         else if (in_group_p(inode->i_gid))
 455                 i >>= 3;
 456         if (!(i & 1) &&
 457             !((inode->i_mode & 0111) && suser())) {
 458                 retval = -EACCES;
 459                 goto exec_error2;
 460         }
 461         if (!(bh = bread(inode->i_dev,bmap(inode,0),inode->i_sb->s_blocksize))) {
 462                 retval = -EACCES;
 463                 goto exec_error2;
 464         }
 465         if (!IS_RDONLY(inode)) {
 466                 inode->i_atime = CURRENT_TIME;
 467                 inode->i_dirt = 1;
 468         }
 469         ex = *((struct exec *) bh->b_data);     /* read exec-header */
 470         if ((bh->b_data[0] == '#') && (bh->b_data[1] == '!') && (!sh_bang)) {
 471                 /*
 472                  * This section does the #! interpretation.
 473                  * Sorta complicated, but hopefully it will work.  -TYT
 474                  */
 475 
 476                 char buf[128], *cp, *interp, *i_name, *i_arg;
 477                 unsigned long old_fs;
 478 
 479                 strncpy(buf, bh->b_data+2, 127);
 480                 brelse(bh);
 481                 iput(inode);
 482                 buf[127] = '\0';
 483                 if (cp = strchr(buf, '\n')) {
 484                         *cp = '\0';
 485                         for (cp = buf; (*cp == ' ') || (*cp == '\t'); cp++);
 486                 }
 487                 if (!cp || *cp == '\0') {
 488                         retval = -ENOEXEC; /* No interpreter name found */
 489                         goto exec_error1;
 490                 }
 491                 interp = i_name = cp;
 492                 i_arg = 0;
 493                 for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) {
 494                         if (*cp == '/')
 495                                 i_name = cp+1;
 496                 }
 497                 if (*cp) {
 498                         *cp++ = '\0';
 499                         i_arg = cp;
 500                 }
 501                 /*
 502                  * OK, we've parsed out the interpreter name and
 503                  * (optional) argument.
 504                  */
 505                 if (sh_bang++ == 0) {
 506                         p = copy_strings(envc, envp, page, p, 0);
 507                         p = copy_strings(--argc, argv+1, page, p, 0);
 508                 }
 509                 /*
 510                  * Splice in (1) the interpreter's name for argv[0]
 511                  *           (2) (optional) argument to interpreter
 512                  *           (3) filename of shell script
 513                  *
 514                  * This is done in reverse order, because of how the
 515                  * user environment and arguments are stored.
 516                  */
 517                 p = copy_strings(1, &filename, page, p, 1);
 518                 argc++;
 519                 if (i_arg) {
 520                         p = copy_strings(1, &i_arg, page, p, 2);
 521                         argc++;
 522                 }
 523                 p = copy_strings(1, &i_name, page, p, 2);
 524                 argc++;
 525                 if (!p) {
 526                         retval = -ENOMEM;
 527                         goto exec_error1;
 528                 }
 529                 /*
 530                  * OK, now restart the process with the interpreter's inode.
 531                  */
 532                 old_fs = get_fs();
 533                 set_fs(get_ds());
 534                 retval = namei(interp,&inode);
 535                 set_fs(old_fs);
 536                 if (retval)
 537                         goto exec_error1;
 538                 goto restart_interp;
 539         }
 540         brelse(bh);
 541         if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC) ||
 542                 ex.a_trsize || ex.a_drsize ||
 543                 ex.a_text+ex.a_data+ex.a_bss>0x3000000 ||
 544                 inode->i_size < ex.a_text+ex.a_data+ex.a_syms+N_TXTOFF(ex)) {
 545                 retval = -ENOEXEC;
 546                 goto exec_error2;
 547         }
 548         if (N_TXTOFF(ex) != BLOCK_SIZE && N_MAGIC(ex) != OMAGIC) {
 549                 printk("%s: N_TXTOFF != BLOCK_SIZE. See a.out.h.", filename);
 550                 retval = -ENOEXEC;
 551                 goto exec_error2;
 552         }
 553         if (!sh_bang) {
 554                 p = copy_strings(envc,envp,page,p,0);
 555                 p = copy_strings(argc,argv,page,p,0);
 556                 if (!p) {
 557                         retval = -ENOMEM;
 558                         goto exec_error2;
 559                 }
 560         }
 561 /* OK, This is the point of no return */
 562         current->dumpable = 1;
 563         for (i=0; (ch = get_fs_byte(filename++)) != '\0';)
 564                 if (ch == '/')
 565                         i = 0;
 566                 else
 567                         if (i < 8)
 568                                 current->comm[i++] = ch;
 569         if (i < 8)
 570                 current->comm[i] = '\0';
 571         if (current->executable)
 572                 iput(current->executable);
 573         i = current->numlibraries;
 574         while (i-- > 0) {
 575                 iput(current->libraries[i].library);
 576                 current->libraries[i].library = NULL;
 577         }
 578         if (e_uid != current->euid || e_gid != current->egid ||
 579             !permission(inode,MAY_READ))
 580                 current->dumpable = 0;
 581         current->numlibraries = 0;
 582         current->executable = inode;
 583         current->signal = 0;
 584         for (i=0 ; i<32 ; i++) {
 585                 current->sigaction[i].sa_mask = 0;
 586                 current->sigaction[i].sa_flags = 0;
 587                 if (current->sigaction[i].sa_handler != SIG_IGN)
 588                         current->sigaction[i].sa_handler = NULL;
 589         }
 590         for (i=0 ; i<NR_OPEN ; i++)
 591                 if ((current->close_on_exec>>i)&1)
 592                         sys_close(i);
 593         current->close_on_exec = 0;
 594         clear_page_tables(current);
 595         if (last_task_used_math == current)
 596                 last_task_used_math = NULL;
 597         current->used_math = 0;
 598         p += change_ldt(ex.a_text,page);
 599         p -= MAX_ARG_PAGES*PAGE_SIZE;
 600         p = (unsigned long) create_tables((char *)p,argc,envc);
 601         current->brk = ex.a_bss +
 602                 (current->end_data = ex.a_data +
 603                 (current->end_code = ex.a_text));
 604         current->start_stack = p;
 605         current->rss = (TASK_SIZE - p + PAGE_SIZE-1) / PAGE_SIZE;
 606         current->suid = current->euid = e_uid;
 607         current->sgid = current->egid = e_gid;
 608         if (N_MAGIC(ex) == OMAGIC)
 609                 read_omagic(inode, ex.a_text+ex.a_data);
 610         eip[0] = ex.a_entry;            /* eip, magic happens :-) */
 611         eip[3] = p;                     /* stack pointer */
 612         if (current->flags & PF_PTRACED)
 613                 send_sig(SIGTRAP, current, 0);
 614         return 0;
 615 exec_error2:
 616         iput(inode);
 617 exec_error1:
 618         for (i=0 ; i<MAX_ARG_PAGES ; i++)
 619                 free_page(page[i]);
 620         return(retval);
 621 }

/* [previous][next][first][last][top][bottom][index][help] */