Operating Systems 2018F Lecture 20

From Soma-notes
Jump to navigation Jump to search

Video

The video from the lecture given on November 21, 2018 is now available.


Sample Questions

  1. [2] When the Linux kernel allocates physical memory, does it use that memory with physical or virtual addresses? How do you know?
  2. [2] Does an mmap system call immediately allocate physical memory? Why or why not?
  3. [2] Assume a process allocates 10GB of memory (using an anonymous mmap) on a machine with 8 GB of physical memory. Is it possible for the call to succeed? If it succeeds, what will happen as data is stored to this allocated memory? Assume that the memory is accessed at random.
  4. [2] Assume we have modified the remember module so it allocates 16K (4 pages) at a time, and assume we have stored in /dev/remember 16K copies of the letter "a".
    • As written, what will a read of /dev/remember return if we use a 4K buffer, starting at the beginning of the file?
    • What will happen if we do a second read, again with a 4K buffer (on the same open file)?
  5. [2] When is memory dynamically allocated in the remember module? When is it freed?
  6. [2] As written, what happens when multiple write calls are made to /dev/remember? What is remembered? Why?
  7. [2] What system call causes getattr() in memoryll.py to be called (on files in a memoryll filesystem)? How did you verify this?
  8. [2] What function in memoryll would you have to change to make it impossible to change file timestamps? Why?
  9. [2] When you run fusermount via execve, what euid does fusermount's process have? What uid does it have?
  10. [2] What is a process's effective uid (euid)? Why is the euid not always equal to its uid?
  11. [2] What system calls does memoryll make when performing file operations on behalf of the kernel? Give one concrete example showing how things work. (Hint: you won't be able to strace memoryll as a regular user.)
  12. [BONUS 5] Implement mmap for the remember device. Show your implementation and explain how it works.


  1. [2] Are man pages a good documentation source when developing kernel modules? Why or why not?
  2. [2] When you load a kernel module, what code is guaranteed to run? (Which functions will definitely be called?) With what privileges will this code run?
  3. [3] You attach a new USB webcam to your computer that is running Linux. The webcam is recognized and works properly.
    • How could you find out what kernel module(s) were loaded, if any, when you attached the webcam?
    • What is a simple way you could prevent those modules from being loaded in the future?
    • What sort of problems could the webcam drivers (modules) cause if they sometimes use dynamically allocated memory improperly (say, by using a buffer after it had been freed)?
  4. [2] What would changing CLASS_NAME in newgetpid.c to "carleton" change in the observable behavior of newgetpid?
  5. [2] How do you safely access userspace memory from a kernel module? Give an example of where we do this in a kernel module covered in class.
  6. [2] What changes need to be made to newgetpid.c to allow it to respond to write requests? Hint: How does newgetpid.c respond to read requests?
  7. [1] If you destroy all of the superblocks in a filesystem, will fsck be able to recover the filesystem? Explain.
  8. [1] When would you expect to find files in the lost+found directory?
  9. [2] When first connecting to a remote host via ssh, you will normally get a message saying something similar to this: "The authenticity of host 'access.scs.carleton.ca (134.117.29.72)' can't be established. RSA key fingerprint is SHA256:MexEKZF0Os0Vl6VTObN70lRf2DFsGfD8DTQ7FKKqVJ4. Are you sure you want to continue connecting (yes/no)?"
    • Why is this question important?
    • What is the "fingerprint" for?
  10. [2] As user student (uid=1000), you run "sshfs <scs-username>@access.scs.carleton.ca:. scs-files", where <scs-username> is your username.
    • Will the files in scs-files have a uid=1000? Why or why not?
    • Assume a file in scs-files is marked as being readable only by the owner. Will you be able to read the contents of this file? Why or why not?
  11. [1] How can you make a file that is 20 GB in size (you can read 20 GB of information from it) but takes up essentially no space on disk?