P4 - Inline Reference Monitors: Sucker-Free Sunday
Due: December 15th, 4:00 PMAssignment Overview
Nobody likes being called a sucker.
You will write a program rewriting pass, called desucker, which
will operate over an llvm bitcode code and create a protected, sucker-free
version of the llvm bitcode program.
Functionally, desucker will inject inline reference monitor
enforcement to enforce a sucker-free safety policy.
The particular details of the safety policy are as follows:
- If the protected program is run on a Sunday, then that program will exit instead of printing the character sequence "sucker", either in isolation or as part of a longer string. The program should operate as usual if it would not have printed "sucker".
- If
desuckeritself is run on a Sunday, then the protected program will instead be altered such that any time it would have printed the character sequence "sucker", in isolation or as part of a longer string, it would instead print the character sequence "friend" in substitution.
Academic Integrity / Collaboration Requirements
The code should be substantially your own. Although you may use auxiliary libraries, the fundamental solution to the assignment must be performed by code you wrote for this assignment. You may form a solo team or team with 1 partner on this assignment. The submission of any team should be no more than incidentally similar in design to any other team's submission. Each member of the team should be indicated in a file called COLLAB.txt included in the submitted tarball. Please fill out COLLAB.txt even if you are working as a solo team. The COLLAB.txt should also disclose any references, tools, or third-party code used as part of completing the assignment.
Each member of a submitting team must be able to explain their solution in detail, both in the design of the code and the operation of each individual line of code. Again, you are responsible for understanding the code you submit - inability to explain code you submitted is considered evidence of academic misconduct.
Details
- For this assignment, you may assume that printing "sucker" occurs via a call to the printf function, though it may occur as a string literal or as a dynamically-constructed string. You are free to protect other means of printing, such as using cout or the print function of another language (recall that LLVM bitcode may be derived from many different source languages).
- For this assignment, the definition of "run on a Sunday" is that the calendar date specified by the system at program invocation time is Sunday.
- For this assignment, you may assume that no attempt will be made to misrepresent the system time (i.e. the program doesn't try to mess with the clock).
Examples
-
The program is protected on a Tuesday, and run on a Sunday:
The program would normally invoke two print statements, This program is cool. and Just kidding! A sucker is born every minute!.
The program should print iThis program is cool. and exit before the second print statement. -
The program is protected on a Tuesday, and run on a Sunday:
The program would normally print Suckers like Chupa Chups are not for me.
This program should be allowed to run without enforcing an exit - you only need to deal with the lowercase string "sucker", here the string is capitalized. -
The program is protected on a Tuesday, and run on a Sunday:
The program would normally print More like mark suckerberg!!
This program should exit before printing the string, even though it is part of a larger word. -
The program is protected on a Sunday, and run on a Tuesday:
The program would normally print More like mark suckerberg!!
This program should print More like mark friendberg!! and otherwise run normally. -
The program is protected on a Tuesday, and run on a Tuesday:
The program would normally print A sensational seersucker suit
This program should operate as normal. -
The program is protected on a Sunday, and run on a Sunday:
The program would normally print A sensational seersucker suit
This program should print A sensational seerfriend suit and otherwise run normally.
Your Submission
You should submit a gzipped tarball named P4.tgz containing a single directory named P4. Within P4 you should include whatever code you need to complete the project as well as your COLLAB.txt.
For the purpose of grading, your code should be able to be tested with the following sequence of commands on the cycle servers:
tar -xf P4.tgz cd P4 mkdir build cmake -B build make -C build ./desucker test1.ll
test1.ll is a file containing LLVM bitcode.
Command-line compliance
As described above, you may use any coding language of your choice to complete
this assignment. However, the above sequence of commands must work without
error for full credit. For example, if you are using python, you might include
a Makefile that immediately exits 0 (since there is no code to build). Furthermore,
you should either include a helper script named graph that
launches the python interpreter with its argument.
Getting Started
A good place to start is the sample LLVM plugin here: code.tgz. Note that you'll need to modify this code and submit code that actually runs clang++ from a frontend script called desucker