1 / 13

Process Execution Rex Chen OS Lab ,NCTU

Process Execution Rex Chen OS Lab ,NCTU. execve(). do_execve() struct binprm is used to store all the data about the file prepare_binprm(). suid sgid sticky. owner group other. type(4 bits). u. g. s. r. w. x. r. w. x. r. w. x. Bits-fileds of i_mode.

kioshi
Download Presentation

Process Execution Rex Chen OS Lab ,NCTU

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Process Execution Rex Chen OS Lab ,NCTU

  2. execve() • do_execve() • struct binprm is used to store all the data about the file • prepare_binprm() suid sgid sticky owner group other type(4 bits) u g s r w x r w x r w x Bits-fileds of i_mode

  3. Bits-fileds of i_mode • type: file type, may be IFREG(regular file), IFDIR(directory), IFBLK(block device), IFCHR(character device) • suid and sgid flags apply to executable file when a user execute the file, if the suid is set, the kernel sets the user’s effective UID to that the owner of the file.

  4. do_execve() • read_exec() : read the first 128 bytes • copy_string() • search_binary_handler()

  5. Setup binary format • binfmt_setup() • register_binfmt() • unregister_binfmt()

  6. Binary format Registered Binary Formats

  7. binfmt_aout.c • demand loading • do_laod_aout_binary() • flush_old_exec() : release the process’s memory, which still contains the old program • do_mmap(): virtual areas for a process can be set up using this function

  8. binfmt_aout.c • struct exec • { • unsigned long a_info; /* Use macros N_MAGIC, etc for access */ • unsigned a_text; /* length of text, in bytes */ • unsigned a_data; /* length of data, in bytes */ • unsigned a_bss; /* length of uninitialized data area for file, in bytes */ • unsigned a_syms; /* length of symbol table data in file, in bytes */ • unsigned a_entry; /* start address */ • unsigned a_trsize; /* length of relocation info for text, in bytes */ • unsigned a_drsize; /* length of relocation info for data, in bytes */ • };

  9. binfmt_aout.c • /* Code indicating object file or impure executable. */ • #define OMAGIC 0407 • /* Code indicating pure executable. */ • #define NMAGIC 0410 • /* Code indicating demand-paged executable. */ • #define ZMAGIC 0413 • /* This indicates a demand-paged executable with the header in the text. • The first page is unmapped to help trap NULL pointer references */ • #define QMAGIC 0314 • /* Code indicating core file. */ • #define CMAGIC 0421

  10. A Process’s Files

  11. A Process’s Virtual Memory

  12. Pages move into main memory uninitialized data pages zero-filled on first access main memory text and Executale file Initialized data stack and heap pages allocation on first access

  13. Process address space per-process kernel stack env strings env_start process memory- resident image argv strings arg_start user stack start_stack brk uninitialized data(bss) symbol table end_data data initialized data end_code executable-file disk image code(text) code(text) start_code a.out header 0 a.out magic number

More Related