text
stringlengths
1
7.76k
source
stringlengths
17
81
884 CASE STUDY 2: WINDOWS 8 CHAP. 11 The system hardware assigns a hardware priority level to interrupts. The CPU also associates a priority level with the work it is performing. The CPU responds only to interrupts at a higher-priority level than it is currently using. Normal prior- ity levels, including the priority l...
clipped_os_Page_884_Chunk7101
SEC. 11.3 SYSTEM STRUCTURE 885 response to a timer interrupt. To avoid blocking threads, timer events which need to run for an extended time should queue requests to the pool of worker threads the kernel maintains for background activities. Asynchronous Procedure Calls The other special kernel control object is the APC...
clipped_os_Page_885_Chunk7102
886 CASE STUDY 2: WINDOWS 8 CHAP. 11 as entering critical regions to defer APCs when acquiring locks or other resources, so that they cannot be terminated while still holding the resource. Dispatcher Objects Another kind of synchronization object is the dispatcher object. This is any ordinary kernel-mode object (the ki...
clipped_os_Page_886_Chunk7103
SEC. 11.3 SYSTEM STRUCTURE 887 locking primitives, like mutexes. When a thread that is waiting for a lock begins running again, the first thing it does is to retry acquiring the lock. If only one thread can hold the lock at a time, all the other threads made runnable might im- mediately block, incurring lots of unneces...
clipped_os_Page_887_Chunk7104
888 CASE STUDY 2: WINDOWS 8 CHAP. 11 pool of high-priority worker threads mentioned earlier which can be used to run bounded tasks by queuing a request and signaling the synchronization event that the worker threads are waiting on. The object manager manages most of the interesting kernel-mode objects used in the execu...
clipped_os_Page_888_Chunk7105
SEC. 11.3 SYSTEM STRUCTURE 889 drivers that can be moved into user-mode processes, where a bug will only trigger the failure of a single driver (rather than bringing down the entire system), the bet- ter. The trend of moving code from the kernel to user-mode processes is expected to accelerate in the coming years. The ...
clipped_os_Page_889_Chunk7106
890 CASE STUDY 2: WINDOWS 8 CHAP. 11 in terms of their location in their files. This differs from physical block caching, as in UNIX, where the system maintains a cache of the physically addressed blocks of the raw disk volume. Cache management is implemented using mapped files. The actual caching is performed by the m...
clipped_os_Page_890_Chunk7107
SEC. 11.3 SYSTEM STRUCTURE 891 tells the operating system how long to maintain it (e.g., until the next reboot or permanently). A publisher atomically updates the state as appropriate. Subscri- bers can arrange to run code whenever an instance of state data is modified by a publisher. Because the WNF state instances co...
clipped_os_Page_891_Chunk7108
892 CASE STUDY 2: WINDOWS 8 CHAP. 11 routines to use for the I/O request packets that flow through the device stack. In some cases the devices in the stack represent drivers whose sole purpose is to filter I/O operations aimed at a particular device, bus, or network driver. Filtering is used for a number of reasons. So...
clipped_os_Page_892_Chunk7109
SEC. 11.3 SYSTEM STRUCTURE 893 The network protocols, such as Windows’ integrated IPv4/IPv6 TCP/IP imple- mentation, are also loaded as drivers using the I/O model. For compatibility with the older MS-DOS-based Windows, the TCP/IP driver implements a special proto- col for talking to network interfaces on top of the Wi...
clipped_os_Page_893_Chunk7110
894 CASE STUDY 2: WINDOWS 8 CHAP. 11 kernel, and executive layers, link in the driver images, and access/update configu- ration data in the SYSTEM hive. After all the kernel-mode components are ini- tialized, the first user-mode process is created using for running the smss.exe pro- gram (which is like /etc/init in UNI...
clipped_os_Page_894_Chunk7111
SEC. 11.3 SYSTEM STRUCTURE 895 to manage the NT namespace and implement objects using a common facility. These are directory, symbolic link, and object-type objects. The uniformity provided by the object manager has various facets. All these objects use the same mechanism for how they are created, destroyed, and ac- co...
clipped_os_Page_895_Chunk7112
896 CASE STUDY 2: WINDOWS 8 CHAP. 11 Object header Object data Object-specific data Object name Directory in which the object lives Security information (which can use object) Quota charges (cost to use the object) List of processes with handles Reference counts Pointer to the type object Type name Access types Access ...
clipped_os_Page_896_Chunk7113
SEC. 11.3 SYSTEM STRUCTURE 897 Handles User-mode references to kernel-mode objects cannot use pointers because they are too difficult to validate. Instead, kernel-mode objects must be named in some other way so the user code can refer to them. Windows uses handles to refer to kernel-mode objects. Handles are opaque val...
clipped_os_Page_897_Chunk7114
898 CASE STUDY 2: WINDOWS 8 CHAP. 11 A: Handle-table entries [512] B: Handle-table pointers [1024] C:Handle-table entries [512] D: Handle-table pointers [32] E: Handle-table pointers [1024] F:Handle-table entries [512] Table pointer Handle-table Descriptor Object Object Object Figure 11-17. Handle-table data structures...
clipped_os_Page_898_Chunk7115
SEC. 11.3 SYSTEM STRUCTURE 899 Procedure When called Notes Open For every new handle Rarely used Parse For object types that extend the namespace Used for files and registry keys Close At last handle close Clean up visible side effects Delete At last pointer dereference Object is about to be deleted Secur ity Get or se...
clipped_os_Page_899_Chunk7116
900 CASE STUDY 2: WINDOWS 8 CHAP. 11 Apart from the object-type callbacks, the object manager also provides a set of generic object routines for operations like creating objects and object types, dupli- cating handles, getting a referenced pointer from a handle or name, adding and subtracting reference counts to the ob...
clipped_os_Page_900_Chunk7117
SEC. 11.3 SYSTEM STRUCTURE 901 object is closed it is important to delete the exclusive access at that point rather than wait for any incidental kernel references to eventually go away (e.g., after the last flush of data from memory). Otherwise closing and reopening a file from user mode may not work as expected becaus...
clipped_os_Page_901_Chunk7118
902 CASE STUDY 2: WINDOWS 8 CHAP. 11 NtCreateFile(\??\C:\foo\bar) IoCallDriver IRP File system filters Win32 CreateFile(C:\foo\bar) OpenObjectByName(\??\C:\foo\bar) I/O manager I/O manager Object manager IopParseDevice(DeviceObject,\foo\bar) C: s Device stack NTFS NtfsCreateFile() (5) IoCallDriver IoCompleteRequest Use...
clipped_os_Page_902_Chunk7119
SEC. 11.3 SYSTEM STRUCTURE 903 6. The device objects encountered as the IRP heads toward the file sys- tem represent file-system filter drivers, which may modify the I/O op- eration before it reaches the file-system device object. Typically these intermediate devices represent system extensions like antivirus filters. ...
clipped_os_Page_903_Chunk7120
904 CASE STUDY 2: WINDOWS 8 CHAP. 11 Type Description Process User process Thread Thread within a process Semaphore Counting semaphore used for interprocess synchronization Mutex Binar y semaphore used to enter a critical region Event Synchronization object with persistent state (signaled/not) ALPC port Mechanism for i...
clipped_os_Page_904_Chunk7121
SEC. 11.3 SYSTEM STRUCTURE 905 links allow a name in one part of the object namespace to refer to an object in a different part of the object namespace. Each device known to the operating system has one or more device objects that contain information about it and are used to refer to the device by the system. Finally, ...
clipped_os_Page_905_Chunk7122
906 CASE STUDY 2: WINDOWS 8 CHAP. 11 The implementation of DLLs is simple in concept. Instead of the compiler emitting code that calls directly to subroutines in the same executable image, a level of indirection is introduced: the IAT (Import Address Table). When an ex- ecutable is loaded it is searched for the list of...
clipped_os_Page_906_Chunk7123
SEC. 11.3 SYSTEM STRUCTURE 907 kernel and services implemented in user-mode processes. Both the kernel and process provide private address spaces where data structures can be protected and service requests can be scrutinized. However, there can be significant performance differences between services in the kernel vs. s...
clipped_os_Page_907_Chunk7124
908 CASE STUDY 2: WINDOWS 8 CHAP. 11 from an attacker attempting to exploit a vulnerability. As a result more and more services in Windows are turned off by default, particularly on versions of Windows Server. 11.4 PROCESSES AND THREADS IN WINDOWS Windows has a number of concepts for managing the CPU and grouping re- s...
clipped_os_Page_908_Chunk7125
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 909 but code that relies on these fields must query them often just to see if they hav e changed. As with many performance hacks, it is a bit ugly, but it works. Processes Processes are created from section objects, each of which describes a memory object backed by a file on d...
clipped_os_Page_909_Chunk7126
910 CASE STUDY 2: WINDOWS 8 CHAP. 11 resource management is that once a process is in a job, all processes’ threads in those processes create will also be in the job. There is no escape. As suggested by the name, jobs were designed for situations that are more like batch processing than ordinary interactive computing. ...
clipped_os_Page_910_Chunk7127
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 911 are completely unaware of fibers, and applications that attempt to use fibers as if they were threads will encounter various failures. The kernel has no knowledge of fibers, and when a fiber enters the kernel, the thread it is executing on may block and the kernel will sch...
clipped_os_Page_911_Chunk7128
912 CASE STUDY 2: WINDOWS 8 CHAP. 11 model that UNIX has. Each of these threads is allocated its own stack and its own memory to save its registers when not running. The two threads appear to be a sin- gle thread because they do not run at the same time. The user thread operates as an extension of the kernel thread, ru...
clipped_os_Page_912_Chunk7129
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 913 Name Description Notes Job Collection of processes that share quotas and limits Used in AppContainers Process Container for holding resources Thread Entity scheduled by the ker nel Fiber Lightweight thread managed entirely in user space Rarely used Thread pool Task-or ient...
clipped_os_Page_913_Chunk7130
914 CASE STUDY 2: WINDOWS 8 CHAP. 11 token so it can perform operations on the client’s behalf. (In general a service can- not use the client’s actual token, as the client and server may be running on dif- ferent systems.) Threads are also the normal focal point for I/O. Threads block when perform- ing synchronous I/O,...
clipped_os_Page_914_Chunk7131
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 915 1. The actual search path for finding the program to execute is buried in the library code for Win32, but managed more explicitly in UNIX. 2. The current working directory is a kernel-mode concept in UNIX but a user-mode string in Windows. Windows does open a handle on the...
clipped_os_Page_915_Chunk7132
916 CASE STUDY 2: WINDOWS 8 CHAP. 11 left to user-mode code that can use the handle on the new process to manipulate its virtual address space directly. To support the POSIX subsystem, native process creation has an option to cre- ate a new process by copying the virtual address space of another process rather than map...
clipped_os_Page_916_Chunk7133
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 917 be used over a network but do not provide guaranteed delivery. Finally, they allow the sending process to broadcast a message to many receivers, instead of to just one receiver. Both mailslots and named pipes are implemented as file systems in Windows, rather than executiv...
clipped_os_Page_917_Chunk7134
918 CASE STUDY 2: WINDOWS 8 CHAP. 11 Semaphores are kernel-mode objects and thus have security descriptors and hand- les. The handle for a semaphore can be duplicated using DuplicateHandle and pas- sed to another process so that multiple processes can synchronize on the same sem- aphore. A semaphore can also be given a...
clipped_os_Page_918_Chunk7135
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 919 the event is cleared. An alternative operation is PulseEvent, which is like SetEvent except that if nobody is waiting, the pulse is lost and the event is cleared. In con- trast, a SetEvent that occurs with no waiting threads is remembered by leaving the ev ent in the signa...
clipped_os_Page_919_Chunk7136
920 CASE STUDY 2: WINDOWS 8 CHAP. 11 Win32 API Function Description CreateProcess Create a new process CreateThread Create a new thread in an existing process CreateFiber Create a new fiber ExitProcess Ter minate current process and all its threads ExitThread Ter minate this thread ExitFiber Ter minate this fiber Switc...
clipped_os_Page_920_Chunk7137
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 921 5. The memory manager creates the address space for the new process by allocating and initializing the page directories and the virtual ad- dress descriptors which describe the kernel-mode portion, including the process-specific regions, such as the self-map page-directory...
clipped_os_Page_921_Chunk7138
922 CASE STUDY 2: WINDOWS 8 CHAP. 11 15. If NtCreateUserProcess was successful, there is still some work to be done. Win32 processes have to be registered with the Win32 subsys- tem process, csrss.exe. Kernel32.dll sends a message to csrss telling it about the new process along with the process and thread handles so it...
clipped_os_Page_922_Chunk7139
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 923 In case 1, the thread is already in the kernel to carry out the operation on the dis- patcher or I/O object. It cannot possibly continue, so it calls the scheduler code to pick its successor and load that thread’s CONTEXT record to resume running it. In case 2, the running...
clipped_os_Page_923_Chunk7140
924 CASE STUDY 2: WINDOWS 8 CHAP. 11 class of its process. The allowed values are: time critical, highest, above normal, normal, below normal, lowest, and idle. Time-critical threads get the highest non- real-time scheduling priority, while idle threads get the lowest, irrespective of the priority class. The other prio...
clipped_os_Page_924_Chunk7141
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 925 To improve the scalability of the scheduling algorithm for multiprocessors with a high number of processors, the scheduler tries hard not to have to take the lock that protects access to the global array of priority lists. Instead, it sees if it can di- rectly dispatch a t...
clipped_os_Page_925_Chunk7142
926 CASE STUDY 2: WINDOWS 8 CHAP. 11 Next thread to run Priority System priorities User priorities Zero page thread 31 24 16 8 1 0 Idle thread Figure 11-26. Windows supports 32 priorities for threads. busy. The amount of boost depends on the I/O device, typically 1 for a disk, 2 for a serial line, 6 for the keyboard, a...
clipped_os_Page_926_Chunk7143
SEC. 11.4 PROCESSES AND THREADS IN WINDOWS 927 12 4 8 12 Does a down on the semaphore and blocks Semaphone Semaphone Blocked Running Ready Waiting on the semaphore Would like to do an up on the semaphore but never gets scheduled (a) (b) Figure 11-27. An example of priority inversion. problem is well known under the nam...
clipped_os_Page_927_Chunk7144
928 CASE STUDY 2: WINDOWS 8 CHAP. 11 11.5.1 Fundamental Concepts In Windows, every user process has its own virtual address space. For x86 ma- chines, virtual addresses are 32 bits long, so each process has 4 GB of virtual ad- dress space, with the user and kernel each receiving 2 GB. For x64 machines, both the user an...
clipped_os_Page_928_Chunk7145
SEC. 11.5 MEMORY MANAGEMENT 929 memory is accessible only while running in kernel mode. The reason for sharing the process’ virtual memory with the kernel is that when a thread makes a system call, it traps into kernel mode and can continue running without changing the mem- ory map. All that has to be done is switch to...
clipped_os_Page_929_Chunk7146
930 CASE STUDY 2: WINDOWS 8 CHAP. 11 Pagefiles An interesting trade-off occurs with assignment of backing store to committed pages that are not being mapped to specific files. These pages use the pagefile. The question is how and when to map the virtual page to a specific location in the pagefile. A simple strategy wou...
clipped_os_Page_930_Chunk7147
SEC. 11.5 MEMORY MANAGEMENT 931 Windows supports up to 16 pagefiles, normally spread out over separate disks to achieve higher I/O bandwidth. Each one has an initial size and a maximum size it can grow to later if needed, but it is better to create these files to be the maxi- mum size at system installation time. If it...
clipped_os_Page_931_Chunk7148
932 CASE STUDY 2: WINDOWS 8 CHAP. 11 sequence of two or more pages that are consecutive in the virtual address space. Of course, processes do not have to manage their memory; paging happens auto- matically, but these calls give processes additional power and flexibility. Win32 API function Description Vir tualAlloc Res...
clipped_os_Page_932_Chunk7149
SEC. 11.5 MEMORY MANAGEMENT 933 11.5.3 Implementation of Memory Management Windows, on the x86, supports a single linear 4-GB demand-paged address space per process. Segmentation is not supported in any form. Theoretically, page sizes can be any power of 2 up to 64 KB. On the x86 they are normally fixed at 4 KB. In add...
clipped_os_Page_933_Chunk7150
934 CASE STUDY 2: WINDOWS 8 CHAP. 11 particular address can be found efficiently. This scheme supports sparse address spaces. Unused areas between the mapped regions use no resources (memory or disk) so they are essential free. Page-Fault Handling When a process starts on Windows, many of the pages mapping the program’...
clipped_os_Page_934_Chunk7151
SEC. 11.5 MEMORY MANAGEMENT 935 format and is determined by the memory manager. For example, for an unmapped page that must be allocated and zeroed before it may be used, that fact is noted in the page-table entry. N X 63 AVL Physical page number 62 52 51 12 AVL 11 9 G 8 P A T 7 D 6 A 5 P C D 4 P W T 3 U / S 2 R / W 1 ...
clipped_os_Page_935_Chunk7152
936 CASE STUDY 2: WINDOWS 8 CHAP. 11 an access violation and usually results in termination of the process. Access viola- tions are often the result of bad pointers, including accessing memory that was freed and unmapped from the process. The third case has the same symptoms as the second one (an attempt to write to a ...
clipped_os_Page_936_Chunk7153
SEC. 11.5 MEMORY MANAGEMENT 937 The memory manager can allocate pages as needed using either the free list or the standby list. Before allocating a page and copying it in from disk, the memory manager always checks the standby and modified lists to see if it already has the page in memory. The prepaging scheme in Windo...
clipped_os_Page_937_Chunk7154
938 CASE STUDY 2: WINDOWS 8 CHAP. 11 CR3 PD 0x300 Self-map: PD[0xc0300000>>22] is PD (page-directory) Virtual address (a): (PTE *)(0xc0300c00) points to PD[0x300] which is the self-map page directory entry Virtual address (b): (PTE *)(0xc0390c84) points to PTE for virtual address 0xe4321000 (a) 1100 0000 00 11 1001 000...
clipped_os_Page_938_Chunk7155
SEC. 11.5 MEMORY MANAGEMENT 939 The working set manager runs every second, called from the balance set man- ager thread. The working-set manager throttles the amount of work it does to keep from overloading the system. It also monitors the writing of pages on the modified list to disk to be sure that the list does not ...
clipped_os_Page_939_Chunk7156
940 CASE STUDY 2: WINDOWS 8 CHAP. 11 X X X X State Cnt WS PT Other Next Clean Dirty Clean Active Clean Dirty Active Dirty Free Free Zeroed Active Active Zeroed 13 12 11 20 10 8 4 7 6 5 4 3 6 2 1 14 0 14 Standby Modified Free Zeroed Page tables Page-frame number database Zeroed List headers 9 Figure 11-33. Some of the m...
clipped_os_Page_940_Chunk7157
SEC. 11.5 MEMORY MANAGEMENT 941 kernel stacks are unpinned from physical memory and their pages are moved to the standby or modified lists, also shown as (1). Tw o other system threads, the mapped page writer and the modified page writer, wake up periodically to see if there are enough clean pages. If not, they take pa...
clipped_os_Page_941_Chunk7158
942 CASE STUDY 2: WINDOWS 8 CHAP. 11 The store manager optimizes where and how physical memory pages are backed by the persistent stores in the system. It also implements optimization techniques such as copy-on-write sharing of identical physical pages and compression of the pages in the standby list to effectively inc...
clipped_os_Page_942_Chunk7159
SEC. 11.6 CACHING IN WINDOWS 943 The Windows cache-manager facilities are shared among all the file systems. Because the cache is virtually addressed according to individual files, the cache manager is easily able to perform read-ahead on a per-file basis. Requests to ac- cess cached data come from each file system. Vi...
clipped_os_Page_943_Chunk7160
944 CASE STUDY 2: WINDOWS 8 CHAP. 11 and play) and power management for devices and the CPU—all using a fundamen- tally asynchronous structure that allows computation to overlap with I/O transfers. There are many hundreds of thousands of devices that work with Windows. For a large number of common devices it is not eve...
clipped_os_Page_944_Chunk7161
SEC. 11.7 INPUT/OUTPUT IN WINDOWS 945 a convenient point for making a clean backup of their persistent state on the vol- ume. Once all the applications are ready, the system initializes the snapshot of the volume and then tells the applications that they can continue. The backup is made of the volume state at the point...
clipped_os_Page_945_Chunk7162
946 CASE STUDY 2: WINDOWS 8 CHAP. 11 operations for setting parameters, as well as calls for flushing system buffers, and so on. At the Win32 layer these APIs are wrapped by interfaces that provide high- er-level operations specific to particular devices. At the bottom, though, these wrappers open devices and perform t...
clipped_os_Page_946_Chunk7163
SEC. 11.7 INPUT/OUTPUT IN WINDOWS 947 the directory or detailed information about each file that is needed for an extended directory listing. Since this is really an I/O operation, all the standard ways of reporting that the I/O completed are supported. NtQuer yVolumeInfor mationFile is like the directory query operati...
clipped_os_Page_947_Chunk7164
948 CASE STUDY 2: WINDOWS 8 CHAP. 11 the attributes of a specific file—but these are just wrappers around the other I/O manager operations we have listed and did not really need to be implemented as separate system calls. There are also system calls for dealing with I/O completion ports, a queuing facility in Windows t...
clipped_os_Page_948_Chunk7165
SEC. 11.7 INPUT/OUTPUT IN WINDOWS 949 Driver Framework) for writing drivers as services that execute in the kernel, but with many of the details of WDM made automagical. Since underneath it is the WDM that provides the driver model, that is what we will focus on in this section. Devices in Windows are represented by de...
clipped_os_Page_949_Chunk7166
950 CASE STUDY 2: WINDOWS 8 CHAP. 11 I/O Request Packets Figure 11-37 shows the major fields in the IRP. The bottom of the IRP is a dy- namically sized array containing fields that can be used by each driver for the de- vice stack handling the request. These stack fields also allow a driver to specify the routine to ca...
clipped_os_Page_950_Chunk7167
SEC. 11.7 INPUT/OUTPUT IN WINDOWS 951 IRP to devices while it is being processed are reused when the I/O operation has finally completed to provide memory for the APC control object used to call the I/O manager’s completion routine in the context of the original thread. There is also a link field used to link all the o...
clipped_os_Page_951_Chunk7168
952 CASE STUDY 2: WINDOWS 8 CHAP. 11 separating this work from the device-specific part, driver writers are freed from learning how to control the bus. They can just use the standard bus driver in their stack. Similarly, USB and SCSI drivers have a device-specific part and a generic part, with common drivers being supp...
clipped_os_Page_952_Chunk7169
SEC. 11.8 THE WINDOWS NT FILE SYSTEM 953 use them. FAT-32 uses 32-bit disk addresses and supports disk partitions up to 2 TB. There is no security in FAT -32 and today it is really used only for tran- sportable media, like flash drives. NTFS is the file system developed specifically for the NT version of Windows. Start...
clipped_os_Page_953_Chunk7170
954 CASE STUDY 2: WINDOWS 8 CHAP. 11 NTFS is a hierarchical file system, similar to the UNIX file system. The sepa- rator between component names is ‘‘ \’’, howev er, instead of ‘‘/’’, a fossil inherited from the compatibility requirements with CP/M when MS-DOS was created (CP/M used the slash for flags). Unlike UNIX t...
clipped_os_Page_954_Chunk7171
SEC. 11.8 THE WINDOWS NT FILE SYSTEM 955 CP/M, where each directory entry was called an extent. A bitmap keeps track of which MFT entries are free. The MFT is itself a file and as such can be placed anywhere within the volume, thus eliminating the problem with defective sectors in the first track. Furthermore, the file...
clipped_os_Page_955_Chunk7172
956 CASE STUDY 2: WINDOWS 8 CHAP. 11 Record 1 is a duplicate of the early portion of the MFT file. This information is so precious that having a second copy can be critical in the event one of the first blocks of the MFT ever becomes unreadable. Record 2 is the log file. When struc- tural changes are made to the file s...
clipped_os_Page_956_Chunk7173
SEC. 11.8 THE WINDOWS NT FILE SYSTEM 957 Attribute Description Standard infor mation Flag bits, timestamps, etc. File name File name in Unicode; may be repeated for MS-DOS name Secur ity descr iptor Obsolete. Secur ity infor mation is now in $Extend$Secure Attr ibute list Location of additional MFT records, if needed O...
clipped_os_Page_957_Chunk7174
958 CASE STUDY 2: WINDOWS 8 CHAP. 11 The next three attributes deal with how directories are implemented. Small ones are just lists of files but large ones are implemented using B+ trees. The logged utility stream attribute is used by the encrypting file system. Finally, we come to the attribute that is the most import...
clipped_os_Page_958_Chunk7175
SEC. 11.8 THE WINDOWS NT FILE SYSTEM 959
clipped_os_Page_959_Chunk7176
960 CASE STUDY 2: WINDOWS 8 CHAP. 11 109 108 106 105 103 102 100 Run #m+1 Run n Run #k+1 Run m MFT 105 Run #1 MFT 108 Run #k
clipped_os_Page_960_Chunk7177
SEC. 11.8 THE WINDOWS NT FILE SYSTEM 961
clipped_os_Page_961_Chunk7178
962 CASE STUDY 2: WINDOWS 8 CHAP. 11 in the device stack inserted into the IRP as the request was being made. A driver that wants to tag a file associates a reparse tag and then watches for completion re- quests for file open operations that failed because they encountered a reparse point. From the block of data that i...
clipped_os_Page_962_Chunk7179
SEC. 11.8 THE WINDOWS NT FILE SYSTEM 963 Compressed 0 16 32 47 7 0 30 37 24 31 85 8 40 92 23 55 Disk addr Original uncompressed file Compressed Uncompressed
clipped_os_Page_963_Chunk7180
964 CASE STUDY 2: WINDOWS 8 CHAP. 11 new files moved to them or created in them to be encrypted as well. The actual en- cryption and decryption are not managed by NTFS itself, but by a driver called EFS (Encryption File System), which registers callbacks with NTFS. EFS provides encryption for specific files and directo...
clipped_os_Page_964_Chunk7181
SEC. 11.9 WINDOWS POWER MANAGEMENT 965 the current generation of multiprocessors, both hibernation and resume can be per- formed in a few seconds even on systems with many gigabytes of RAM. An alternative to hibernation is standby mode where the power manager re- duces the entire system to the lowest power state possib...
clipped_os_Page_965_Chunk7182
966 CASE STUDY 2: WINDOWS 8 CHAP. 11 when to run such background activities. For example, checking for updates might occur only once a day or at the next time the device is charging its battery. A set of system brokers provide a variety of conditions which can be used to limit when background activity is performed. If ...
clipped_os_Page_966_Chunk7183
SEC. 11.10 SECURITY IN WINDOWS 8 967 failed. Windows prevents this attack by instructing users to hit CTRL-ALT-DEL to log in. This key sequence is always captured by the keyboard driver, which then invokes a system program that puts up the genuine login screen. This procedure works because there is no way for user proc...
clipped_os_Page_967_Chunk7184
968 CASE STUDY 2: WINDOWS 8 CHAP. 11 access control list assigned to objects created by the process if no other ACL is specified. The user SID tells who owns the process. The restricted SIDs are to allow untrustworthy processes to take part in jobs with trustworthy processes but with less power to do damage. Finally, t...
clipped_os_Page_968_Chunk7185
SEC. 11.10 SECURITY IN WINDOWS 8 969 access. This simple example is illustrated in Fig. 11-46. The SID Everyone refers to the set of all users, but it is overridden by any explicit ACEs that follow. Security descriptor Header Owner's SID Group SID DACL SACL Header Audit Marilyn 111111 Security descriptor Header Allow E...
clipped_os_Page_969_Chunk7186
970 CASE STUDY 2: WINDOWS 8 CHAP. 11 initialized using InitializeSecur ityDescr iptor. This call fills in the header. If the owner SID is not known, it can be looked up by name using LookupAccountSid. It can then be inserted into the security descriptor. The same holds for the group SID, if any. Normally, these will be...
clipped_os_Page_970_Chunk7187
SEC. 11.10 SECURITY IN WINDOWS 8 971 performs this check by looking at the caller’s access token and the DACL associ- ated with the object. It goes down the list of ACEs in the ACL in order. As soon as it finds an entry that matches the caller’s SID or one of the caller’s groups, the access found there is taken as defi...
clipped_os_Page_971_Chunk7188
972 CASE STUDY 2: WINDOWS 8 CHAP. 11 Yet another change was the introduction of what Microsoft calls UA C (User Account Control). This is to address the chronic problem in Windows where most users run as administrators. The design of Windows does not require users to run as administrators, but neglect over many release...
clipped_os_Page_972_Chunk7189
SEC. 11.10 SECURITY IN WINDOWS 8 973 11.10.4 Security Mitigations It would be great for users if computer software did not have any bugs, particu- larly bugs that are exploitable by hackers to take control of their computer and steal their information, or use their computer for illegal purposes such as distrib- uted de...
clipped_os_Page_973_Chunk7190
974 CASE STUDY 2: WINDOWS 8 CHAP. 11 the address space. Recent work shows how running programs can be rerandom- ized every few seconds, making attacks even more difficult (Giuffrida et al., 2012). Heap hardening is a series of mitigations added to the Windows imple- mentation of the heap that make it more difficult to ...
clipped_os_Page_974_Chunk7191
SEC. 11.10 SECURITY IN WINDOWS 8 975 Many of these mitigations are under the control of compiler and linker flags. If applications, kernel device drivers, or plug-in libraries read data into executable memory or include code without /GS and ASLR enabled, the mitigations are not present and any vulnerabilities in the pr...
clipped_os_Page_975_Chunk7192
976 CASE STUDY 2: WINDOWS 8 CHAP. 11 I/O performance for many applications because read operations can be satisfied without accessing the disk. I/O is performed by device drivers, which follow the Windows Driver Model. Each driver starts out by initializing a driver object that contains the addresses of the procedures ...
clipped_os_Page_976_Chunk7193
CHAP. 11 PROBLEMS 977 6. Win32 does not have signals. If they were to be introduced, they could be per process, per thread, both, or neither. Make a proposal and explain why it is a good idea. 7. An alternative to using DLLs is to statically link each program with precisely those li- brary procedures it actually calls,...
clipped_os_Page_977_Chunk7194
978 CASE STUDY 2: WINDOWS 8 CHAP. 11 18. Windows uses a facility called Autoboost to temporarily raise the priority of a thread that holds the resource that is required by a higher-priority thread. How do you think this works? 19. In Windows it is easy to implement a facility where threads running in the kernel can tem...
clipped_os_Page_978_Chunk7195
CHAP. 11 PROBLEMS 979 Give an example of how Windows might do something similar using NtCreateProcess. (Hint: Consider processes that host DLLs to implement functionality provided by a third party). 31. A file has the following mapping. Give the MFT run entries. Offset 0 1 2 3 4 5 6 7 8 9 10 Disk address 50 51 52 22 24...
clipped_os_Page_979_Chunk7196
980 CASE STUDY 2: WINDOWS 8 CHAP. 11 41. The regedit command can be used to export part or all of the registry to a text file under all current versions of Windows. Save the registry several times during a work session and see what changes. If you have access to a Windows computer on which you can install software or h...
clipped_os_Page_980_Chunk7197
12 OPERATING SYSTEM DESIGN In the past 11 chapters, we have covered a lot of ground and taken a look at many concepts and examples relating to operating systems. But studying existing operating systems is different from designing a new one. In this chapter we will take a quick look at some of the issues and trade-offs ...
clipped_os_Page_981_Chunk7198
982 OPERATING SYSTEM DESIGN CHAP. 12 12.1 THE NATURE OF THE DESIGN PROBLEM Operating system design is more of an engineering project than an exact sci- ence. It is hard to set clear goals and meet them. Let us start with these points. 12.1.1 Goals In order to design a successful operating system, the designers must hav...
clipped_os_Page_982_Chunk7199
SEC. 12.1 THE NATURE OF THE DESIGN PROBLEM 983 manipulate these data structures. For example, users can read and write files. The primitive operations are implemented in the form of system calls. From the user’s point of view, the heart of the operating system is formed by the abstractions and the operations on them av...
clipped_os_Page_983_Chunk7200