Local Attacks

From ICO wiki
Jump to navigationJump to search

int power(long base, long exponent) {

   int counter;
   int result = 1;
   for (counter = 0; counter < exponent; counter++)
       result *= base;
   return result;

}


/* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */

cmp r1, #0 /* Compare exponent to 0 */ mov r2, #1 /* Place constant 1 in register r2,

                                    this corresponds to result = 1 in C code */

ble .L2 /* Exponent was not less than 0, so no jump to L2 mov r3, #0 /* Place constant 0 in register r3,

                                    this corresponds to variable counter */

add r3, r3, #1 /* Perform r3 = 0 + 1 which results in 1 being stored to r3

                                    this corresponds to first invocation of counter++ in C code */

cmp r3, r1 /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */ mul r2, r0, r2 /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2

                                    this corresponds to first invocation of result *= base in C code */

bne .L3 /* The comparison resulted in counter being not equal to exponent, so we jump back to L3

                                    this corresponds to first invocation of counter < exponent in C code */

add r3, r3, #1 /* Perform r3 = 1 + 1 which results in 2 being stored to r3

                                    this corresponds to second invocation of counter++ in C code */

cmp r3, r1 /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */ mul r2, r0, r2 /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2

                                    this corresponds to second invocation of result *= base in C code */

bne .L3 /* The comparison resulted in counter being not equal to exponent, so we jump back to L3

                                    this corresponds to second invocation of counter < exponent in C code */

add r3, r3, #1 /* Perform r3 = 2 + 1 which results in 3 being stored to r3

                                    this corresponds to third invocation of counter++ in C code */

cmp r3, r1 /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */ mul r2, r0, r2 /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2

                                    this corresponds to third invocation of result *= base in C code */

bne .L3 /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */

mov r0, r2 /* Copy register r2 contents (125) to register r0 */ bx lr /* Jump back to caller */ /* Function returns with 125 placed in r0 this is where caller function should expect the return value */ /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */  

Storage abstractions

 What is a block device?

 In computing (specifically data transmission and data storage), a block, sometimes called a physical record, is a sequence of bytes or bits, usually containing some whole number of records, having a maximum length, a block size.[1] Data thus structured are said to be blocked. The process of putting data into blocks is called blocking, while deblocking is the process of extracting data from blocks. Blocked data is normally stored in a data buffer and read or written a whole block at a time.

 What is logical block addressing and what are the benefits compared to older cylinder-head-sector addressing method in terms of harddisks?

Logical block addressing (LBA) is a common scheme used for specifying the location of blocks of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressing scheme; blocks are located by an integer index, with the first block being LBA 0, the second LBA 1, and so on. Cylinder-head-sector, also known as CHS, is an early method for giving addresses to each physical block of data on a hard disk drive. In the case of floppy drives, for which the same exact diskette medium can be truly low-level formatted to different capacities, this is still true.

 What is a disk partition? Disk partitioning is the creation of one or more regions on a hard disk or other secondary storage, so that an operating system can manage information in each region separately.[1] Partitioning is typically the first step of preparing a newly manufactured disk, before any files or directories have been created

 What is a file system?

In computing, a file system (or filesystem) is used to control how data is stored and retrieved. Without a file system, information placed in a storage area would be one large body of data with no way to tell where one piece of information stops and the next begins. By separating the data into individual pieces, and giving each piece a name, the information is easily separated and identified. Taking its name from the way paper-based information systems are named, each group of data is called a "file". The structure and logic rules used to manage the groups of information and their names is called a "file system".

 What is journaling in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.

A journaling file system is a file system that keeps track of changes not yet committed to the file system's main part by recording the intentions of such changes in a data structure known as a "journal", which is usually a circular log. In the event of a system crash or power failure, such file systems can be brought back online quicker with lower likelihood of becoming corrupted

In the Linux operating system, JFS is supported with the kernel module (since the kernel version 2.4.18pre9-ac4) and the complementary userspace utilities packaged under the name JFSutils. Most Linux distributions support JFS, unless it is specifically removed due to space restrictions or other concerns.