Operating Systems 2020W: Assignment 4: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
==Tutorial 8 Questions== | ==Tutorial 8 Questions== | ||
# Can a process change where data and code is stored in virtual memory? What about in physical memory? | # [1] Can a process change where data and code is stored in virtual memory? What about in physical memory? | ||
# If two processes mmap the same library, will that library (necessarily) have the same virtual addresses for both processes? What about the same physical addresses? | # [1] If two processes mmap the same library, will that library (necessarily) have the same virtual addresses for both processes? What about the same physical addresses? | ||
# What system calls does 3000memview2 use to get physical addresses? Are any of these new (ones we haven't previously seen in class)? Why? | # [1] What system calls does 3000memview2 use to get physical addresses? Are any of these new (ones we haven't previously seen in class)? Why? | ||
# Who has access to /dev/ | # [1] Who has access to /dev/3000physicalview? How do you know (from the code)? | ||
# List all of the page table lookups that get_physical() does in 3000physicalview.c. Why are there so many lookups? | # [1] List all of the page table lookups that get_physical() does in 3000physicalview.c. Why are there so many lookups? | ||
# Can you do an ioctl call on regular files? Why or why not? | # [1] Can you do an ioctl call on regular files? Why or why not? | ||
# What are the values of PAGE_SHIFT and PAGE_SIZE? Where are they defined? What do they represent? | # [1] What are the values of PAGE_SHIFT and PAGE_SIZE? Where are they defined? What do they represent? | ||
==Tutorial 9 Questions== | ==Tutorial 9 Questions== | ||
# Where is FILTER_PID defined? Where is it used? | # [1] Where is FILTER_PID defined? Where is it used? | ||
# How could you make 3000shellwatch.py watch for events in any process, not just a specific one? What events would it then report? | # [1] How could you make 3000shellwatch.py watch for events in any process, not just a specific one? What events would it then report? | ||
# Make 3000shellwatch.py monitor all instances of 3000shell by checking a process's comm property. Be sure to remove the PID argument. (Hint: see bashreadline) | # [1] Make 3000shellwatch.py monitor all instances of 3000shell by checking a process's comm property. Be sure to remove the PID argument. (Hint: see bashreadline) | ||
# What code of 3000shellwatch runs in userspace? What runs in kernel space? | # [1] What code of 3000shellwatch runs in userspace? What runs in kernel space? | ||
# Why does 3000shellwatch require root privileges to run? Give an example of a small change you could make to 3000shellwatch that would give an unprivileged user the ability to see or do something that they normally can't. | # [1] Why does 3000shellwatch require root privileges to run? Give an example of a small change you could make to 3000shellwatch that would give an unprivileged user the ability to see or do something that they normally can't. | ||
# How are a uprobe and a uretprobe similar? How are they different? | # [1] How are a uprobe and a uretprobe similar? How are they different? | ||
# What is the signals dictionary used for? | # [1] What is the signals dictionary used for? | ||
# As presented in the tutorial, does 3000shellwatch have to use eBPF to achieve its goals? Could it instead have used ptrace? Argue for or against, based on the level of access you've seen gdb and strace have to processes using the ptrace system call. | # [1] As presented in the tutorial, does 3000shellwatch have to use eBPF to achieve its goals? Could it instead have used ptrace? Argue for or against, based on the level of access you've seen gdb and strace have to processes using the ptrace system call. | ||
# On line 69 of bpfprogram.c, does sys_exit refer to the exit system call? Explain. | # [1] On line 69 of bpfprogram.c, does sys_exit refer to the exit system call? Explain. | ||
==Multiple Choice== | ==Multiple Choice== | ||
Line 109: | Line 109: | ||
<li>filter() in bpfprogram.c is called (select all that apply) | <li>filter() in bpfprogram.c is called (select all that apply) | ||
<ol style="list-style-type:lower-alpha"> | <ol style="list-style-type:lower-alpha"> | ||
<li>Every time the specified 3000shell process makes a system call</li> | <li>Every time the specified 3000shell process makes a system call, but not when other processes make system calls</li> | ||
<li>Every time any 3000shell process makes a system call</li> | <li>Every time any 3000shell process makes a system call, but not when other processes make system calls</li> | ||
<li>Every time any process makes a system call</li> | <li>Every time any process makes a system call</li> | ||
<li>Every time any process calls fgets()</li> | <li>Every time any process calls fgets()</li> | ||
Line 127: | Line 127: | ||
</li> | </li> | ||
<li>What can I probe using | <li>What can I probe using an eBPF program? | ||
<ol style="list-style-type:lower-alpha"> | <ol style="list-style-type:lower-alpha"> | ||
<li>system calls</li> | <li>system calls</li> | ||
Line 177: | Line 177: | ||
</li> | </li> | ||
</ol> | </ol> | ||
==Solutions== | |||
[https://homeostasis.scs.carleton.ca/~soma/os-2020w/solutions/assign4-sol.txt Assignment 4 (short answer) solutions)] |
Latest revision as of 20:07, 3 April 2020
Below are questions for Assignment 4. Written answers will not be graded. Instead, related multiple choice questions will be posted on cuLearn by March 31st and will be due by 2:30 PM on April 3, 2020.
Tutorial 8 Questions
- [1] Can a process change where data and code is stored in virtual memory? What about in physical memory?
- [1] If two processes mmap the same library, will that library (necessarily) have the same virtual addresses for both processes? What about the same physical addresses?
- [1] What system calls does 3000memview2 use to get physical addresses? Are any of these new (ones we haven't previously seen in class)? Why?
- [1] Who has access to /dev/3000physicalview? How do you know (from the code)?
- [1] List all of the page table lookups that get_physical() does in 3000physicalview.c. Why are there so many lookups?
- [1] Can you do an ioctl call on regular files? Why or why not?
- [1] What are the values of PAGE_SHIFT and PAGE_SIZE? Where are they defined? What do they represent?
Tutorial 9 Questions
- [1] Where is FILTER_PID defined? Where is it used?
- [1] How could you make 3000shellwatch.py watch for events in any process, not just a specific one? What events would it then report?
- [1] Make 3000shellwatch.py monitor all instances of 3000shell by checking a process's comm property. Be sure to remove the PID argument. (Hint: see bashreadline)
- [1] What code of 3000shellwatch runs in userspace? What runs in kernel space?
- [1] Why does 3000shellwatch require root privileges to run? Give an example of a small change you could make to 3000shellwatch that would give an unprivileged user the ability to see or do something that they normally can't.
- [1] How are a uprobe and a uretprobe similar? How are they different?
- [1] What is the signals dictionary used for?
- [1] As presented in the tutorial, does 3000shellwatch have to use eBPF to achieve its goals? Could it instead have used ptrace? Argue for or against, based on the level of access you've seen gdb and strace have to processes using the ptrace system call.
- [1] On line 69 of bpfprogram.c, does sys_exit refer to the exit system call? Explain.
Multiple Choice
- A process can potentially control, at runtime
(select all that are true)
- location of a variable in virtual memory
- location of a variable in physical memory
- location of a library in virtual memory
- location of a library in physical memory
- What file operations does /dev/physicalview (explicitly) support?
(select all that are true)
- open
- read
- write
- ioctl
- seek
- If you wanted to make /dev/physicalview only usable by the root user, what value should *mode have on line 161?
- 0666
- 0640
- 0004
- 0200
- 0600
- What does the permission mask 0666 represent when converted to flags as
shown by ls -l?
- rwxr-xrw-
- rw-rw-rw-
- r-xr-xr-x
- rw-r--r--
- r--r--r--
- In order to get the page table entry for a page, how many lookups would you expect on a 32 bit x86 system? What about a 64 bit x86 system? Be sure to include the lookup of the top-level page table and the final page table entry.
- 1 and 4
- 1 and 5
- 2 and 5
- 2 and 4
- 3 and 5
- Which of these support ioctl operations? Select all that apply.
- /home/student
- /home/student/.bashrc
- /dev/ones
- /dev/physicalview
- /dev/pts/0
- Which of the following is NOT true in the Linux kernel source code?
- PAGE_SIZE is defined in terms of PAGE_SHIFT
- PAGE_SHIFT is always 12
- PAGE_SHIFT determines the number of bytes in a page
- PAGE_SHIFT is dictated by the underlying CPU
- PAGE_SHIFT represents the number of bits in the page offset
- What does the -D option to a C compiler do?
- It specifies a macro for the C pre-processor
- It is roughly equivalent to a #define option in the source code
- It can be used to set compile-time options.
- It allows for source code to be compiled in different ways without changing the source
- All of the above
- filter() in bpfprogram.c is called (select all that apply)
- Every time the specified 3000shell process makes a system call, but not when other processes make system calls
- Every time any 3000shell process makes a system call, but not when other processes make system calls
- Every time any process makes a system call
- Every time any process calls fgets()
- Every time any process receives a signal
- Code in which of the following source files runs in kernel space? (select all that apply)
- 3000shell.c
- 3000shellwatch.py
- bpfprogram.c
- 3000memview2.c
- 3000physicalview.c
- What can I probe using an eBPF program?
- system calls
- kernel function calls
- process function calls
- signals
- all of the above
- In the Linux kernel source, different signals (such as SIGKILL) are specified using
- Inline-specified numbers (e.g., 9, 15)
- Named constants specified using #define's
- Constant strings, e.g. "SIGKILL"
- Pointers to strings
- Elements of a union
- In bpfprogram.c, sys_exit (on line 69) refers to
- The exit system call
- The exit system call, when called by 3000shell
- The exit system call, when called by the specified PID
- The exiting of any system call made by 3000shell
- The exiting of any system call
- The ptrace system call is used by (select all that apply)
- ps
- bash
- ls
- strace
- gdb
- eBPF programs are safer than kernel modules because
- They can only be run by the root user
- They are compiled just before being loaded
- They are checked by a verifier when being loaded into the kernel
- They can only access parts of kernel memory
- They are written in a safe, garbage-collected language (Python)