Unit 3 - Design & Evaluation and Hardware Security (Part 2) Flashcards
What happens it the total amount of computer memory is not sufficient?
If the total amount of computer memory is not sufficient, some processes may be temporarily swapped out of memory to holding files on hard disk to make room for other processes. If memory is limited, this can seriously reduce the performance of the system, as it takes time to move data from memory to disk and vice versa.
What are pages and the paging process?
Over time, simply inserting items wherever they will fit leads to poor utilisation of memory. In particular:
- the remaining memory space becomes fragmented;
- it becomes increasingly difficult to find places to store items, especially if they need contiguous space (i.e. a set of memory locations with consecutive addresses).
Dividing up computer memory into fixed sized storage units, and splitting items to be put into memory (e.g. processes) into pieces of the appropriate size leads to better utilisation of storage. Such a process is known as paging, where the fixed sized units of storage are called pages. Note that the pages allocated to a program can be scattered across main memory, and do not need to be adjacent. Also, the set of memory pages allocated to a process can vary during the lifetime of the process (as it is swapped in and outof memory).
What is process isolation?
In order to execute a program it must be in main memory.
One of the operating system’s jobs is to load programs into main memory.
Different regions of main memory are occupied by different programs, and hence the area of memory allocated to one program must be protected against access/interference by other programs running in other areas of memory. This is known as process isolation.
What are privilege levels?
We also need to be able to distinguish between operating system programs and application programs. We can then control which programs are able to execute privileged instructions, i.e. instructions which would enable one application program to interfere with another,or to make uncontrolled accesses to resources.
Modern processors are able to run at a variety of privilege levels, depending on which process is currently executing. These privilege levels can be used to restrict access to critical functionality. Certain machine instructions are only available to programs running ata higher privilege level.
In what scenarios would hardware protection not be required?
In a multi-tasking computer, processes share resources, such as CPU time and main memory:
- each process is allocated certain parts of main memory (using paging) and a certain proportion of the processor execution cycles;
- the system design needs to ensure that one process cannot access memory addresses assigned to a differentprocess or to the OS.
However,hardware protection is notrequired if:
- we assume all programs are correctand trustworthy;
- there is no operating system; or
- we do not require multi-tasking.
What are some such privileges instructions?
Modern computers run an operating system and application programs. Running a program causes the execution ofinstructions. Some instructions are privileged, such as those involving:
- directly accessing main memory (i.e. without the addresses being translated using the virtual memory managementfunctionality);
- changing certain registers.
Application programs should notbe able to execute privileged instructions.
What must the CPU be able to do to prevent applications running privileged instructions?
In order to prevent application programs running privileged instructions, the CPU must be able to:
- distinguish between OS and application programs;
- prevent some programs from executing privileged instructions.
This is achieved using privilege levels.
What is the difference between system mode and user mode?
The operating system and the hardware can be protected by associating each program with a privilege level:
- the operating system runs with a different privilege level from application programs;
- one of the control registers on the processor indicates the level at which the CPU is currently operating;
- this enables a distinction to be made between operating system and applications.
These two privilege levels are sometimes known as system mode and user mode.
Some instructions are notavailable if the processor is executing in system mode
How many privileges modes does x86 architecture have?
The more recent Intel x86 architecture actually supports a total of four different privilege levels. These are numbered 0, 1, 2 and 3, where 0 is the most privileged and 3 is the least privileged. System mode is assigned privilege level 0 and user mode is assigned level 3.
Both Unix and Windows only use two (of the four available) privilege levels, namely levels 0 and 3
What are intel privilege levels also known as?
There are four defined privilege levels (also known as protection modes or rings) for Intel processors, known as Ring 0,Ring 1, Ring 2 and Ring 3.
Their purpose is to separate the OS from applications runningon the OS.
In principle they also enable the OS to separate (layer) internal OS functions to help the OS protect itself. However,in practice this does not happen.
How do the protection rings differ from how they were intended to be used?
Unfortunately, the four privilege levels (or rings as they are commonly known) provided by the Intel processor architecture have not really been used as was originally intended, so that the layering of OS functions is notachieved.
In the picture, the current use of the rings is shown on the left, and the original intention on the right. This picture applies for both Unix and Windows
The OS vendors have notused all four rings – they only use two.
This has serious security implications.
All OS activities share the same hardware security level.
Every time a single OS component (e.g. a driver) changes, the security of the entire OS is affected.
Many attacks resultfrom use of ring 0 for all system activities.
Whilst this could be fixed in principle, in practice it would require the OS, most drivers,and some applications to be rewritten – this is simply not a viable strategy
What protection ring do most OS drivers require?
The OS requires drivers (i.e. pieces of software mediating access between OS and hardware) to access hardware devices, such as disk drives, LAN cards, and graphics adaptors.
Most drivers require access to ring 0 to work properly.
Allowing multiple drivers to access ring 0 breaks domain separation (process isolation).
Drivers can cause other problems by trying to access resources used by other drivers – causing the OS to behave erratically.
Some applications require specific versions of a driver – two applications requiring different driver versions will certainly cause issues. On occasion it is possible to install two different drivers for the same device – ensuring correct OS operation in such a case is very difficult
What is the difference between synchronous interrupts and asynchronous interrupts?
- synchronous interrupts are produced by the CPU control unit while executing instructions and are called synchronous because the control unit issues them only after terminating the execution of an instruction
- asynchronous interrupts are generated by other hardware devices at arbitrary times with respect to the CPU clock signals
What are system calls?
User programs often need to privileged operations (e.g. to perform input/output (I/O), to open files, or to read from/write to main memory. However, a user program running in user mode will not be able to execute the necessary instructions. In order to achieve the desired objective, the program generates a software interrupt or system call (e.g. by calling a function provided by the operating system API). As a result:
- the processor switches to system mode;
- a ‘handler’ (an operating system program) running in system mode performs the desired operation;
- once the handler finishes execution, the CPU resumes execution of the user program (back in user mode).
What is an interrupt?
An interrupt is an event that causes the computer to stop what it is doing and (temporarily) do something else in such a way that processing of the original task can be seamlessly resumed. They:
- are used to signal events or conditions to the computer hardware (the CPU) outside ofthe normal execution cycle;
- may be generated by hardware or software;
- are hardware-specific.
Interrupts are said to be asynchronous:
- that is, it is not predictable when an interruptwill occur;
- provisions for interrupt processing have to be added to the basic instruction cycle of the processor.
What is the process routine of an interrupt?
The diagram summarises how interrupts work from the processor’s perspective. Fetching and executing instructions form the ‘normal’ processing cycle.
What is the Interrupt Descriptor Table?
The Interrupt descriptor table (IDT) is used to store the interrupt vectors and the addresses in memory ofthe corresponding interrupt handlers.
The IDT, and the interrupt handlers (i.e. the pieces of software run when an interrupt occurs),are stored in main memory, in an area reserved for OS use.
How is an interrupt processed?
Every interrupt is identified by a numerical value called an interrupt vector that:
- identifies the source ofthe interrupt;
- is associated with a vector-specific program called an interrupt handler;
When the interrupt occurs:
- it causes the appropriate interrupt handler to be executed;
- execution of the original program then recommences once execution of the handler is completed.
What are the use of interrupts?
Uses of interrupts include:
- maximising CPU usage (i.e. so that processing of input/output can be interleaved with running programs):
- I/O devices are much slower than the CPU;
- I/O interrupts are used to tell the CPU that I/O has completed.
- transferring control from a user program to an operating system program:
- application programs are not (or should not be) sufficiently privileged to interactdirectly with the computer;
- instead, as outlined on a previous slide, an application program must make a system call(also known as a supervisor interrupt)
What are some possible attacks on the IDT?
Programs running in system mode (such as the operating system) are trusted, since such programs can perform privileged instructions (and can therefore do anything):
- if an attacker can execute a shell program running in system mode he can completely control the machine;
- executing a program in system mode is often the goal of attacks that exploit buffer overflows.
An attacker able to overwrite the IDT could redirect a system mode interrupt handler to code chosen by the attacker:
- if the attacker then causes that interrupt to occur, the attacker’s code will now run in system mode and control the machine;
This technique was used by the Brain virus (and has been widely used by a range of exploits of system vulnerabilities).
What are exceptions?
All modern processors detect error conditions known as exceptions caused by the execution ofa program. Such errors might, for example,be caused by:
- an attempt to divide a number by 0 (division by zero is undefined);
- an unauthorised attempt to access a protected memory location (giving rise to a ‘general protection error’).
Exceptions are also referred to as traps. There are wide variations in usage; for example, sometimes trap is used to refer to any interrupt, sometimes to any synchronous interrupt, sometimes to any interrupt not associated with input/output, and sometimes only to interrupts caused by instructions with trap in their names.
Exceptions are handled by the operating system following detection by the processor. They:
- occur in response to particular conditions and are said to be synchronous;
- are detected during the standard execution cycle.
Processing ofexceptions and interrupts is very similar:
- each type of exception has an identifier (‘vector”’ and an associated handler, i.e. a piece of software which is executed when the relevantexception occurs.
What does the main memory of a computer consist of?
The main memory of a computer consists of a number (m say) of storage locations. Each location is given a numerical address between 0 and m−1:
- the physical address space is defined by the list of memory addresses: 0, 1, . . . , m−1;
- typically,m = 2n for some n.
Typically, even though a computer word consists of a number of bytes (4 for 32-bit machines and 8 for 64-bit machines), each byte is given a unique address. Since a computer instruction may take up one or more words, the program counter will actually be increased by more than one as it executes an instruction.
Machine instructions identify the operands (i.e. the values being operated on) of an instruction using memory addresses. For example, a machine instruction might specify:
- add the contents of memory address 0x1234 to the contents of the DR register;
- jump to memory address 0x2345 (i.e. setthe program counter to 0x2345).