P3 – File Access Project
Overview
In this project, you will change file access in Bionic Beaver. This project relates to projects 1 and 2, but only
builds on project 1. In project 1, you attached a tag to each process. In project 2, you used part of this tag to
constrain scheduling to prevent a covert channel. In this project, you will implement hierarchical access control
according to Bell-LaPadula (BLP) to eliminate covert information flows (see Figure 1).
Recall that the tag contains two fields:
1. level (the two LSBs, bits 0 and 1) and
2. bitmap (bits 2-30).
As before, two level fields can be compared numerically in a total order: 3 > 2 > 1 > 0. The bitmap fields can be
treated as associating each bit with a need-to-know category. A bitmap with bit b set can be used to represent a
security label indicating that a file contains information specific to category b, or that a user has been cleared to
access information on category b, or that a process has access to category b. In Mandatory Access Control
(MAC), these labels can be used to determine access rights (in addition to the usual discretionary access control
methods).
Figure 1Bell-La Padula Model
COP4600
File access control is decided based on the properties of the process that requests access to a file, and the
properties of that file. In BLP, there are two rules that constrain information flow to be only from less sensitive
to more sensitive, fewer categories to more categories:
1. No read up, and
2. No write down.
Up and down depend upon the labels. A process P with label L = <level, B> is not allowed to read a file F with
label L’ = <level’, B’> if either F level’ > level of P or if any bit is set in F bitmap B’ and is not set in P bitmap
B (i.e., L’ dominates L). That is, a process can only “read down” to a file at the same or lower level, and
containing information associated with a subset of the need-to-know categories for which the process is
authorized. This prevents information from flowing from a more restricted file to a less restricted process. To
prevent information flow from a more restricted process to a less restricted file, a process P with label L =
<level, B> is not allowed to write to a file F with label L’ = <level’, B’> if either P level > level’ of F or if any
bit is set in P’s bitmap B and is not set in F’s bitmap B’ (i.e., L is dominated by L’). That is, a process can only
“write up” to a file at the same or higher level, containing information associated with a superset of the need-toknow categories for which the process is authorized.
When a process requests to open a file, the system must check to determine that the label of the file dominates
the label of the process if write access is desired, or that the label of the file is dominated by the label of the
process if read access is desired, or that the labels are equal if both read and write access are desired. When a
process requests to create a file, the system must ensure that the created file has the same access level and
bitmap as the creating process (i.e., has the least restrictive label for a file to which the process can write).
When the label of a process P is changed by root, it is not allowed to change to a label that is lower than (strictly
dominated by) its current label, because P may hold information at that sensitivity level and category set. Its
label is allowed only to change to either increase its level, to set one or more bit in the bitmap, or both. In
addition, the process must not have any file open with write access that has a label lower than the desired label.
For the purposes of this project, we will make an exception for devices, such as tty, keyboard, disk, etc.
You will provide system calls to set and to get the current tag of a file, with get allowed by any process but set
only permitted to a process owned by the root user. You will also create library wrapper functions to access
these system calls. You will modify the set and get process tag system calls from Project 1 to enforce the
modified rules given above. You will modify the access control decisions for opening a file to enforce BLP,
with an exception for devices. You will document your code with comments and a short report and submit the
project via Canvas. No screencast or man pages will be required for this project.
NOTE: Take Snapshots in VirtualBox! You will most likely brick your machine at some point during this
or other projects, and you will not want to start from scratch. No, seriously – take snapshots!
Structure
The project is broken into four main parts:
1) Modify the file system so that all normal files are associated with a tag of the same structure as used in
projects 1 and 2, and provide system calls and library functions to get and set the tag of a file. Any
process can read a file’s tag, but only superuser processes may write it, and only if the file is not
currently open by any process.
2) Modify the system calls from project 1 to allow the tag of a process to be increased by a process owned
by root subject to the constraints imposed by open files as noted above. This call will fail if the process
whose label is increasing has a file open with write access that has a tag that does not dominate the new
tag of the process.
3) Change the file access control logic so that a file can only be opened with read access if the tag of the
process dominates the tag of the file, and a file can only be opened with write access if the tag of the file
dominates the tag of the process.
4) Create a report to explain what you did.
While exact implementation may vary, the library functions must match the signatures laid out in this
document, the system calls must get and set tags properly, and the file access control system must enforce BLP
correctly (except for device files).
System Calls
You will create new system calls named get_file_tag and set_file_tag. These will allow the tag for a given
file to be obtained or modified, respectively. Other aspects of their signatures may vary. Files that are
currently open by a process must not have their tags changed and an error must be returned.
You will modify the systems calls from Project 1 that access the tags associated with processes to follow the
rules given above. Invalid tag modification must fail and return an error.
All your code modifications must include appropriate comments wherever changes are made including your
name and the date. Your code as always should adhere to good practices, including no manifest constants,
good identifier naming, and modularity.
Static Library
As in Project 1, you will create a static library that provides an API to invoke the system calls in a directory
named tags. This will be composed of a header files with name tags.h and a static library file named
libtags.a. You will also need to provide a Makefile for this library in the tags directory. All other sources
must be contained within the tags directory. No relocatable object files or executables must be in the tags
directory. Please note, the names of these files must match exactly!
You will create a tarred gzip file of the tags directory (without .o or .a files or executables) with name
tags.tar.gz. When testing your code, we will decompress the archive, enter the tags directory, and build
the library. All functions enumerated below must be made available by including “tags.h”. See Submission
for details.
Library Functions
These functions provide primary functionality to user programs. They should be made available by
including <tags.h>.
int set_file_tag(char filename[], int new_tag)
invokes system call which attempts to change the file identified by filename to the new tag value
new_tag. Returns new_tag on success, and -1 otherwise, with errno set to an unused value you will
document to explain the failure.
int get_file_tag(char filename[])
invokes system call which reads the tag value of the file identified by file_name. Returns the tag value on
success, and -1 otherwise, with errno set to an unused value you will document to explain the failure.
You must also modify the library functions from Project 1 as well, to account for the additional restrictions
on changing the tag of a process depending on its current tag and the files it has open with write access.
Note on Persistence
It is beyond the scope of the project to modify the file-system such that tags are stored along with files. As
such, your file tags will be lost whenever the system reboots.
Access Control
In addition to the system calls to get and set tags for files and processes, you must modify the parts of the
file system that deal with access control so that a process is only able to open normal files for which their
labels are compatible as specified above. Your system must only perform these label checks for normal
files, but not on other types of files present in Linux. See the man pages for stat(2) and inode(7) for further
information.
Manual Pages
Manual pages are not required for this project.
Testing
You should test your code for all behavioral cases. You will include this information in your report and
demonstrate the tests in your screencast video. Testing is an important skill in software development, and you
have had examples from earlier projects. We may provide some limited test functions, but you must devise
additional tests to completely test your implementation.
Submissions
You will submit the following at the end of this project:
Report (p3.txt) in man page format on Canvas
Kernel Patch File (p3.diff) on Canvas that includes source code and makefile(s)
Compressed tar archive (tags.tar.gz) for the new tags library on Canvas
Report
Your report will explain
1. how you implemented the new system calls,
2. how you modified the system calls from Project 1, and
3. how you changed the file access control mechanisms,
including for each what changes were made to which files and why each change was made. Each file changed
will be displayed with its full path on a line by itself, followed by the explanation of what the file contains,
how it was changed, and why. The report will include a description of how testing was performed along with
any known bugs. The report must be created using man format and be named p3.txt. The report should be no
more than three pages and should cover all relevant aspects of the project. The report must be organized and
formatted professionally – this is not a memo!
Screencast
No screencast is required for this project.
Patch File
The patch file will include all changes to all files from a clean install of our initial version of Bionic Beaver
(i.e., not modified by Project 1 or Project 2) in a single patch. Applying the patches and remaking the
necessary parts of the OS, then rebooting and then building the test code (which we will also copy over)
should compile the test program and link in the new library object code.
Compressed Tar Archive
The file tags.tar.gz should be a gzip-compressed tar archive. The required structure of this archive is
detailed in the “Grading” section, below. Extracting the archive, entering the tags directory, and then building
with make should create the libtags.a file.
Grading
We will test your project by applying the patch by switching to /usr/rep/src/kernel and running:
$ git apply p3.diff
$ make && sudo make install && sudo make modules_install
We urge you to make sure that these commands work on a clean install before submitting. Note that compilation should
be done with the make call, and anything that requires root access should only be done with the make install or make
modules_install.
Compressed Archive (tags.tar.gz)
Your compressed tar file should have the following directory/file structure:
tags.tar.gz
tags.tar
tags (directory)
tags.h
harness.h
Makefile
(Other source files)
To build the library, we will execute these commands (from a non-kernel source directory):
$ tar zxvf tags.tar.gz
$ cd tags
$ make
$ cd ..
To link against the library from the parent directory, we will execute this command:
$ cc -o program_name sourcefile.c -L./tags -ltags
Please test your library build and linking before submission! If your library does not compile it will result in
zero credit (0, none, goose-egg) for the library portion of the project.
See the assignment rubric for details on grading.
Grading Rubric
| Criterion | Points | |
| Report (13) | Covers all files changed | 4 |
| Explains how and why files changed | 4 | |
| Testing, bugs | 3 | |
| Clarity, completeness, formatting | 2 |
| Code (2) | Code is properly commented and understandable | 1 |
| Code follows best practices (no manifest constants, good naming, etc.) | 1 | |
| Functionality (35) | System calls set and get file and process tags correctly, sets errno | 15 |
| System enforces file open, creation, and access correctly, returns error codes | 20 | |
| Expected Qualities | On time, patch file works, makes, compiles, links, runs – deductions if not | 0 |
| Total | 50 |
Helpful References
Documentation/filesystems/vfs.txt (within the kernel source directory)
https://www.kernel.org/doc/htmldocs/filesystems/vfs.html
http://manpages.ubuntu.com/manpages/bionic/man3/errno.3.html
http://manpages.ubuntu.com/manpages/bionic/man2/stat.2.html
http://manpages.ubuntu.com/manpages/bionic/man7/inode.7.html
The post P3 – File Access Project appeared first on My Assignment Online.