--------------------------------------- Operating Systems (CSE 506) HW2 Submission --------------------------------------- Submitted on 07-November-2010 by --------------------------------------- CSE506-G28 - Ankush Gulati (SB ID: 107569466) - Aneesh Sood (SB ID: 107234056) --------------------------------------------------------------- This README file is a descripton of the solution design of HW2. --------------------------------------------------------------- Table of Contents ------------------ 1.) Design 1.1) ADDRESS SPACE OPERATIONS Operations Mounting 1.2) DATA PAGE ENCRYPTION Description 2.) Code Modifications 2.1) wrapfs.h 2.2) file.c 2.3) main.c 2.4) lookup.c 2.5) mmap.c 2.6) fs.h 3.) How to run the Code? 3.1) Description 3.2) Mounting 3.3) Passing the key for encryption 4.) Assumptions 5.) References ---------------------------------------------------------------------BEGIN--------------------------------------------------------------------------- 1.) Design ------ 1.1) TASK 1: ADDRESS SPACE OPERATIONS -------------------------------- We use the "wrapfs" stackable file system as a starting point and modify the code to support address_space operations instead of the existing vm_ops operations. Operations ---------- The existing wrapfs code implements the following functions to perform the read and write operations whenever a vm_ops->fault is called: - wrapfs_read - wrapfs_write We instead use do_sync_read and do_sync_write which in turn call our newly written functions (readpage and wrapfs_write_begin wrapfs_write_end) respectively to perform the above mentioned read/write operations. Mounting -------- We allow the user to choose his operations (VM_OP or ADDRESS_OP) at the time of mount by using the mmap option. When enabled, the file system uses the address_space ops implementation (ADDRESS_OP). When the "mmap" option isn't given, it uses the default/current behavior (VM_OP). 1.2) TASK 2: DATA PAGE ENCRYPTION ---------------------------- Description ----------- - To support data page encryption, we implement AES 256 encryption. To persist the passkey, the encryption key is stored in the superblock of wrapfs. We have added an additional field to the superblock of wrapfs to hold this passkey. - Further, we have implemented a new IOCTL function which takes the passkey from the user and persists the passkey into the superblock. - The user can pass the encryption key using a simple userprogram which in turn calls the ioctl function. - The implementation allows to SET, CHANGE & RESET the key as required in the assignment. Whenever, the user does a passkey CHANGE, all the inodes are invalidated and the dcache is shrinked so that the when the changed key is passed, the files are picked up from the lower FS and not the cache. 2.) Code Modifications ------------------- To implement the above discussed design changes, we have modified the following files in Wrapfs wherein we have modified/implemented the below mentioned functions: 2.1) wrapfs.h --------- Objects/Variables ----------------- - A new file_operations object has been declared for the address operations. 2.2) file.c ------ Objects/Variables ----------------- - A new global variable has been declared which stores the value of mounting type. - A new character array has been declared to copy the passkey from ioctl into the superblock. - The file_operations object(initialized in wrapfs.h) has been initialized here with the required addr_op functions. Functions --------- - Implemented a new function "wrapfs_ioctl_password" that is called by a user function to pass the password. - IOCTL numbr is 'a'. - It takes 3 arguments namely: a) File Descriptor (Dummy File Descriptor) ?b) cmd c) Passkey (32 byte long) 2.3) main.c ------ Functions --------- Modified the wrapfs_get_sb function to support the mounting options by checking for the user provided mount command. 2.4) lookup.c -------- Functions --------- Modified the wrapfs_iget function to map different set of inode file ops for VM_OP and ADDR_OP. 2.5) mmap.c ------- Objects/Variables ----------------- - Set the .readpage, .writepage, .write_begin, .write_end with the newly implemented functions in the file_operations object created for ADDR_OP. Functions --------- - Implemented the function wrapfs_write_begin which replaces wrapfs_write functionality for VM_OP. - Implemented the function wrapfs_write_end which along with the above function replaces wrapfs_write functionality for VM_OP. - Implemented the function kernel_encryption to encrypt the file contents written. - Implemented the function kernel_decryption to decrypt the contents of the file taken from the lower fs. - Implemented the function readpage to provide the above discussed design changes for providing address op level read functionality. - Implemented the function wrapfs_writepage to provide the above discussed design changes for providing address op level write functionality. ??2.6) fs.h ---- 3.) How to Run the code? -------------------- 3.1) Description ----------- The implementation support BOTH methods VM_OP & ADDR_OP. - When the user mounts hdb1, he can give a mount-time option "mmap": when enabled, uses the ADDR_OPS. - When the "mmap" option isn't given, the default functionality (VM_OP) works. - It returns an error, when any option other than above two passed. 3.2) Mounting -------- - Mounting hdb1 as ext3 with mount name X. $mount -t ext3 /dev/hdb1 - Mounting wrapfs on top of ext3 at point X as Y. $mount -t wrapfs - Mounting wrapfs on top of ext3 at point X as Y WITH "mmap" option. $mount -t wrapfs -o mmap 3.3) Passing the key for encryption ------------------------------ Description ----------- The user can pass the encryption key as required in the assignment. Setting the key to 00000 allows you to RESET the key. User Program ------------ - To assist the graders to run the code we are providing a small utility which takes the 32 byte passkey from the user and passes it to the ioctl function. - A new folder 'utility' has been created in the fs/wrapfs structure wherein user_program.c, user_program.h & a Makefile have been placed. - To run the User Program: Run the Makefile placed inside the 'utility' folder, an executable will be generated by the name of user_program. The user needs to provide the path(please read the assumptions) where wrapfs has been mounted and the passkey. $cd /usr/src/hw2-cse506g28/fs/wrapfs/utility $Makefile $./user_program 4.) Assumptions ----------- The user program requires the file descriptor of a file which is placed where wrapfs has been mounted because the ioctl functionality requires a file descriptor as an argument. 5.) References ---------- We have referred to the following source code bases & web resources and adapted them as per our requirements. - readpage : old unionfs readpage - writepage : old unionfs writepage - write_end : ecryptfs write_end - write_begin : ecryptfs write_begin - user_program (ioctl usage): internet (http://lists.freebsd.org/pipermail/freebsd-drivers/2005-November/000078.html) ---------------------------------------------------------------------END---------------------------------------------------------------------------