Starting from:

$30

CSE506-Project 1: System Call Solved




The goal of this project is to get used to Linux development environment and modify Linux kernel source code. The project is split into two parts. The first part is analyzing a given user-space socket application and adding printk() to the system call entries in Linux kernel. The second part is to add one new system call which encrypts a given string and prints out encrypted string to kernel message. 



         /code-socket.tar.gz
         /printk.patch
         /printk.png
         /syscall.patch
         /syscall.tar.gz
         /syscall.png

112233445
112233445
112233445
112233445
112233445
112233445
112233445

Recommended Background Reading 

• Socket Programming in C/C++
• GNU Make in Detail for Beginners • printk()
• git diff
• ERRNO(3)
• GETOPT(3) 

Part 1. Adding printk()
The attached source code code-socket.tar.gz is a simple socket application that exchanges 

messages between a server and client. It consists of three files as shown in below. 

P1.1: Understanding source code 

[10 points] Carefully read above three source file to understand how a simple network client/server works. Once you completely understand each file, add comments of each line (M1-M10, S1-S9, and C1-C7) explaining what the line means. Turn in the gzip-ed tarball named code-socket.tar.gz. 
$ cd code-socket
$ ls
client.c  Makefile  server.c

$  tar czvf code-socket.tar.gz code-socket/
code-socket/
code-socket/client.c
code-socket/server.c

code-socket/Makefile

P1.2: Adding printk() 

Now you understand how the user-space application works. To understand how a kernel system call is called, print any message at the very beginning of system call implementations of accept() and connect() in Linux kernel v5.8. Check if the modified kernel prints out messages you added when you run the network client/server. Then create a patch against kernel v5.8 using git diff command and turn in the patch named printk.patch. 

P1.3: Test your kernel 

 Take the screenshot of your kernel debug message using
client/server. Run , client, and dmesg in one ssh session using . Turn in the screenshot named . 

Part 2: Adding a new system call 

Add a new system call named sys_s2_encrypt() that takes two arguments, a NULL-terminated string and an encryption key, which is a positive integer between 1 and 5. The system call encrypts the given string by simply adding the given integer number. For example, it encrypts "hello" to "ifmmp" by adding 1 to each character of the string. After encryption, it prints out the encrypted string using The system call returns 0 when everything is okay. If the encryption key is out of bound, it returns . 

P2.1: Implementing the system call 

[10 points] You should implement the system call in a separate file under linux/kernel directory. Then create a patch against kernel v5.8 using command and turn in the patch named syscall.patch. 

P2.2: Writing a test program 

[10 points] Write a simple test program takes two options, and calls sys_s2_encrypt() with the string and key from the command line. You should implement command line argument processing using GETOPT(3) and the code should be able to build using make and clean using make clean. The program prints out the return value of sys_s2_encrypt(). Turn in gzip-ed tarball of the source code and Makefile, named 

P2.3: Test your system call 

[5 points] Take a screenshot of your kernel debug message using while running your test program. Run your test program and dmesg in one ssh session using . Turn in the screenshot named syscall.png. 
printk.png 
server 
dmesg 
while running the network 
tmux 
printk(). 
git 
diff 
-s string 
 
-k 
key 
syscall.tar.gz. 
dmesg 
EINVAL 
tmux 

More products