<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F%3A_Assignment_4</id>
	<title>Operating Systems 2019F: Assignment 4 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F%3A_Assignment_4"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F:_Assignment_4&amp;action=history"/>
	<updated>2026-06-03T00:40:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F:_Assignment_4&amp;diff=22562&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;For this assignment please work on the questions below.  There are 12 questions worth 20 points.  While you will be able to submit your answers, by default &#039;&#039;&#039;they will not be...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F:_Assignment_4&amp;diff=22562&amp;oldid=prev"/>
		<updated>2020-03-20T02:21:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;For this assignment please work on the questions below.  There are 12 questions worth 20 points.  While you will be able to submit your answers, by default &amp;#039;&amp;#039;&amp;#039;they will not be...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;For this assignment please work on the questions below.  There are 12 questions worth 20 points.  While you will be able to submit your answers, by default &amp;#039;&amp;#039;&amp;#039;they will not be graded.&amp;#039;&amp;#039;&amp;#039; Instead, a multiple choice quiz (based on the questions below) will be made available by Dec. 2nd and will be due by 4 PM on Dec. 4th.  The grade for this quiz will substitute for Assignment 4.&lt;br /&gt;
&lt;br /&gt;
In class on December 4th solutions for the assignment questions below and the Assignment 4 Quiz will be given and discussed.&lt;br /&gt;
&lt;br /&gt;
If you feel your answers to the quiz do not demonstrate what you actually learned, you can make an appointment with Prof. Somayaji to grade your submitted Assignment 4 answers (assuming you submitted them by Dec. 4th) before Dec. 20th.&lt;br /&gt;
&lt;br /&gt;
==Questions==&lt;br /&gt;
&lt;br /&gt;
# [1] Can you load a Linux kernel module more than once?  Explain briefly.&lt;br /&gt;
# [1] For the modules we have created in class, does the code run continuously, or does it run in response to certain events?  Explain, and be specific.&lt;br /&gt;
# [1] When the kernel does a printk(), does it write directly to /var/log/kern.log?  Explain.&lt;br /&gt;
# [1] The makefile for a Linux kernel module is generally very simple; however, building a module seems to be a bit complicated, generating lots of files.  Where is the module build process getting instructions for doing all this work?&lt;br /&gt;
# [1] If you change line 22 in the ones module to define CLASS_NAME to be &amp;quot;OSclass&amp;quot;, will this change the observable behavior of the module?  Explain briefly.&lt;br /&gt;
# [1] When doing the work for a system call, how does the kernel keep track of which process made that system call (so it does the work on behalf of that process)?&lt;br /&gt;
# [2] How does the format of data returned by getdents(2) differ from that returned by readdir(3) (at a high level)?  What is a key motivation for this difference?&lt;br /&gt;
# [2] How can you change the magic_prefix for the rootkit without changing the code of the module? How is this information passed to the kernel at runtime?&lt;br /&gt;
# [2] When the kernel allocates memory for its own use, does it refer to that memory using virtual or physical addresses?  How does the remember module show this?&lt;br /&gt;
# [2] What is a significant reason why the kernel uses functions such as copy_to_user() when accessing process memory?  Why not just access this memory directly?&lt;br /&gt;
# [2] Change the ones module so that it will allow writes, and the first character of whatever is written will become the character that is repeatedly output when reading (instead of &amp;#039;1&amp;#039;).  What changes do you need to make?&lt;br /&gt;
# [4] How could you make a &amp;quot;spooky rootkit&amp;quot; (based on 3000rootkit) that would randomly (with a .01 probability on each call to getdents) insert a file &amp;quot;BOO!&amp;quot; with an inode of 9999 into the stream of returned files?  Note that you can get random bytes using the get_random_bytes() function in the kernel.&lt;br /&gt;
&lt;br /&gt;
==Multiple Choice Questions for Quiz==&lt;br /&gt;
&lt;br /&gt;
# A kernel module is loaded into&lt;br /&gt;
#* its own address space, in userspace.&lt;br /&gt;
#* its own address space, in kernelspace.&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;the same address space as the rest of the kernel.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* the same address space as the insmod process that loaded it.&lt;br /&gt;
# When does kernel module code normally not run?&lt;br /&gt;
#* When a module is loaded&lt;br /&gt;
#* When a module is unloaded&lt;br /&gt;
#* In response to registered events&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;Continuously in the background&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# A printk() is just like a printf(), except it goes straight to the kernel log file /var/log/kern.log.&lt;br /&gt;
#* True&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;False&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# What does the -C option to make do?&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;It says to change to the specified directory before doing anything else&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* It defines the output directory for make&lt;br /&gt;
#* It specifies the compiler make should use to build programs&lt;br /&gt;
#* It tells make to do a parallel build&lt;br /&gt;
# Directories in /sys/class (what doesn&amp;#039;t belong)&lt;br /&gt;
#* contain symbolic links&lt;br /&gt;
#* list devices defined by different subsystems of the kernel&lt;br /&gt;
#* are mostly created by kernel modules&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;take up disk space&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# In the Linux kernel processes are represented as a&lt;br /&gt;
#* process_struct&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;task_struct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* thread_struct&lt;br /&gt;
#* program_struct&lt;br /&gt;
# getdents returns multiple directory entries per call because&lt;br /&gt;
#* Switching from user space to kernel space is expensive&lt;br /&gt;
#* Switching from kernel space to user space is expensive&lt;br /&gt;
#* A directory block on disk will generally hold multiple entries&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;All of the above&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# How does a kernel module get its parameters?&lt;br /&gt;
#* The module reads them from a /etc/module.conf config file.&lt;br /&gt;
#* The module loader writes them to /proc/modules&lt;br /&gt;
#* The module is passed them through a write system call&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;The module has special declarations for parameters that are initialized by the module loading framework&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* The module receives them as parameters to its init function&lt;br /&gt;
# kmalloc()&lt;br /&gt;
#* Can be used by regular processes as a faster, lower-level version of malloc&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;Allocates memory in the kernel with different priorities&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* Only accepts allocation requests that are evenly divisible by the page size&lt;br /&gt;
#* Returns the physical address of allocated memory&lt;br /&gt;
#* All of the above&lt;br /&gt;
# If the kernel makes use of a userspace pointer as if it was a regular pointer, the kernel could&lt;br /&gt;
#* return confidential kernel data to a process&lt;br /&gt;
#* overwrite kernel data it shouldn&amp;#039;t&lt;br /&gt;
#* attempt to write to memory that isn&amp;#039;t writable&lt;br /&gt;
#* attempt to read memory that isn&amp;#039;t readable&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;all of the above&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# When you stat a file, you are getting the contents of&lt;br /&gt;
#* a directory entry&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;an inode&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* a file&amp;#039;s page table&lt;br /&gt;
#* a block on disk&lt;br /&gt;
# Changing the return value of getdents() (as in 3000rootkit) involves&lt;br /&gt;
#* changing file permissions&lt;br /&gt;
#* allocating kernel memory statically&lt;br /&gt;
#* traversing a set of fixed-length records&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;parsing filenames&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#* all of the above&lt;br /&gt;
&lt;br /&gt;
==Solutions==&lt;br /&gt;
&lt;br /&gt;
[https://homeostasis.scs.carleton.ca/~soma/os-2019f/solutions/assign4-sol.txt Assignment 4 solutions]&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>