This chapter describes functions for allocating memory on the heap or stack in C. It discusses brk(), sbrk(), malloc(), and free() for allocating memory on the heap by adjusting the program break and using memory pools. It also covers calloc(), realloc(), memalign(), and alloca() for specialized memory allocation needs, like initializing to zero, resizing blocks, aligned blocks, and stack allocation. Tools for debugging memory allocation like mtrace(), mcheck(), and MALLOC_CHECK are also outlined.
The document discusses the PE/COFF file format used in Windows. It explains that PE/COFF is based on the older COFF format, with a PE header added. It describes the different sections contained in a PE/COFF file like .text, .data, .rdata, and debug sections. It also explains the image headers, section tables, and symbol tables contained in the COFF and PE parts of the file format.
Tlpi chapter 38 writing secure privileged programsShu-Yu Fu
?
This document discusses guidelines for securely writing privileged programs. It recommends operating with least privilege by dropping privileges when they are not needed and reacquiring them only as required. It also recommends confining the process using capabilities or chroot jails, being careful of signals and race conditions, avoiding buffer overflows, and checking return values of system calls. The overall aim is to minimize the chances of a privileged program being subverted and to minimize potential damage if subversion occurs.
Each process has a unique process ID and maintains its parent's ID. A process's virtual memory is divided into segments like the stack and heap. When a program runs, its command-line arguments and environment are passed via argc/argv and the environ list. The setjmp() and longjmp() functions allow non-local jumps between functions, but their use should be avoided due to restrictions and compiler optimizations that can affect variable values.
This document summarizes key concepts about file systems in Linux:
1. It describes the structure of file systems including superblocks, inodes, and data blocks. Inodes contain metadata about files and pointers to data blocks.
2. It discusses device files that correspond to devices in the system and are represented in the /dev directory. Each device has a major and minor ID.
3. Journaling file systems like ext4 are described which eliminate the need for lengthy consistency checks after crashes by journaling file system updates.
4. The concept of mounting other file systems at mount points under the single directory hierarchy rooted at / is summarized along with the mount() and umount() system calls.
Pipes and FIFOs allow communication between related processes. Pipes are unidirectional byte streams used to connect the standard output of one process to the standard input of another. FIFOs allow communication between any processes and have names in the file system. Both pipes and FIFOs can experience blocking and deadlocks if processes attempt to read empty or write to full connections. Nonblocking I/O helps prevent these issues.
This document provides an overview of the C programming language under Linux, covering preprocessing, compiling, assembling, linking, libraries, and related tools. It discusses:
1. The four main steps of preprocessing, compiling, assembling, and linking using GNU tools like cpp, cc1, as, and collect2.
2. How to display symbol tables using nm and strip symbols from executables.
3. Creating static libraries with ar and ranlib and linking them, as well as creating shared libraries with gcc and soname.
4. The roles of environment variables like LIBRARY_PATH and LD_LIBRARY_PATH in locating libraries.
This chapter describes functions for allocating memory on the heap or stack in C. It discusses brk(), sbrk(), malloc(), and free() for allocating memory on the heap by adjusting the program break and using memory pools. It also covers calloc(), realloc(), memalign(), and alloca() for specialized memory allocation needs, like initializing to zero, resizing blocks, aligned blocks, and stack allocation. Tools for debugging memory allocation like mtrace(), mcheck(), and MALLOC_CHECK are also outlined.
The document discusses the PE/COFF file format used in Windows. It explains that PE/COFF is based on the older COFF format, with a PE header added. It describes the different sections contained in a PE/COFF file like .text, .data, .rdata, and debug sections. It also explains the image headers, section tables, and symbol tables contained in the COFF and PE parts of the file format.
Tlpi chapter 38 writing secure privileged programsShu-Yu Fu
?
This document discusses guidelines for securely writing privileged programs. It recommends operating with least privilege by dropping privileges when they are not needed and reacquiring them only as required. It also recommends confining the process using capabilities or chroot jails, being careful of signals and race conditions, avoiding buffer overflows, and checking return values of system calls. The overall aim is to minimize the chances of a privileged program being subverted and to minimize potential damage if subversion occurs.
Each process has a unique process ID and maintains its parent's ID. A process's virtual memory is divided into segments like the stack and heap. When a program runs, its command-line arguments and environment are passed via argc/argv and the environ list. The setjmp() and longjmp() functions allow non-local jumps between functions, but their use should be avoided due to restrictions and compiler optimizations that can affect variable values.
This document summarizes key concepts about file systems in Linux:
1. It describes the structure of file systems including superblocks, inodes, and data blocks. Inodes contain metadata about files and pointers to data blocks.
2. It discusses device files that correspond to devices in the system and are represented in the /dev directory. Each device has a major and minor ID.
3. Journaling file systems like ext4 are described which eliminate the need for lengthy consistency checks after crashes by journaling file system updates.
4. The concept of mounting other file systems at mount points under the single directory hierarchy rooted at / is summarized along with the mount() and umount() system calls.
Pipes and FIFOs allow communication between related processes. Pipes are unidirectional byte streams used to connect the standard output of one process to the standard input of another. FIFOs allow communication between any processes and have names in the file system. Both pipes and FIFOs can experience blocking and deadlocks if processes attempt to read empty or write to full connections. Nonblocking I/O helps prevent these issues.
This document provides an overview of the C programming language under Linux, covering preprocessing, compiling, assembling, linking, libraries, and related tools. It discusses:
1. The four main steps of preprocessing, compiling, assembling, and linking using GNU tools like cpp, cc1, as, and collect2.
2. How to display symbol tables using nm and strip symbols from executables.
3. Creating static libraries with ar and ranlib and linking them, as well as creating shared libraries with gcc and soname.
4. The roles of environment variables like LIBRARY_PATH and LD_LIBRARY_PATH in locating libraries.