<?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_Lecture_15</id>
	<title>Operating Systems 2019F Lecture 15 - 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_Lecture_15"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_15&amp;action=history"/>
	<updated>2026-06-02T22:24:21Z</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_Lecture_15&amp;diff=22537&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on November 1, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec15-20191101.m4v is now available]....&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_15&amp;diff=22537&amp;oldid=prev"/>
		<updated>2020-03-20T02:07:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on November 1, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec15-20191101.m4v is now available]....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on November 1, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec15-20191101.m4v is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
The [https://homeostasis.scs.carleton.ca/~soma/os-2019f/solutions/comp3000-midterm-2019f-sol.pdf midterm solutions] are now posted.  If you have questions please ask in a later lecture or on discord.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 15&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
* sshfs&lt;br /&gt;
* ebpf&lt;br /&gt;
&lt;br /&gt;
Mounting filesystems&lt;br /&gt;
 - adding a filesystem to existing file hierarchy, on top of an empty directory&lt;br /&gt;
 - mountpoint directories don&amp;#039;t have to be empty, but anything in them will be hidden as long as another filesystem is mounted on top of it&lt;br /&gt;
 - when you start, the file hierarchy is just the &amp;quot;root&amp;quot; filesystem&lt;br /&gt;
 &lt;br /&gt;
eBPF&lt;br /&gt;
&lt;br /&gt;
First, in general we want to add code to the kernel to extend its functionality&lt;br /&gt;
 - but the kernel is a dangerous place to work&lt;br /&gt;
&lt;br /&gt;
 - entire branch of OS practice that believes you shouldn&amp;#039;t add code&lt;br /&gt;
   to the kernel, better to just do everything in processes,&lt;br /&gt;
   including device drivers, networking stack, filesystems...everything&lt;br /&gt;
   except basic scheduling and process memory management&lt;br /&gt;
   =&amp;gt; microkernels&lt;br /&gt;
&lt;br /&gt;
 - most common way to add code to the linux kernel is kernel modules&lt;br /&gt;
   - modern Linux distributions compile their kernels so as much&lt;br /&gt;
     functionality as possible are in modules&lt;br /&gt;
   - code that is loaded at boot time can (mostly) never be removed, so&lt;br /&gt;
     it always takes up RAM on all systems running that kernel, and that&lt;br /&gt;
     RAM is always physical RAM&lt;br /&gt;
   - modules have an advantage that they only have to be loaded if they are&lt;br /&gt;
     needed&lt;br /&gt;
   &lt;br /&gt;
 - in tutorial 7, we&amp;#039;ll play with kernel modules, but for now we&amp;#039;re doing something else...why?&lt;br /&gt;
&lt;br /&gt;
 * why are modules so bad?&lt;br /&gt;
   - they are DANGEROUS&lt;br /&gt;
     - they run in the same address space as the rest of the kernel&lt;br /&gt;
   - consider all the problems you have with crashing your own C&lt;br /&gt;
     programs...now you&amp;#039;re modifying a gigantic one that&lt;br /&gt;
     you don&amp;#039;t understand, injecting code into it at runtime!&lt;br /&gt;
      - you have access to EVERYTHING in the kernel&amp;#039;s memory address space,&lt;br /&gt;
        including all processes, all users, you got it all&lt;br /&gt;
&lt;br /&gt;
   - module code is fundamentally stronger than code running as root&lt;br /&gt;
   - root has to ask the kernel to do things, module code can just do it&lt;br /&gt;
     - kernel can say no, e.g. filesystem busy&lt;br /&gt;
&lt;br /&gt;
eBPF is great because...&lt;br /&gt;
 - you can access almost anything in the kernel&lt;br /&gt;
 - but it is safe and much, much easier!&lt;br /&gt;
 - very difficult to crash the kernel or corrupt memory from eBPF,&lt;br /&gt;
   but you can still do lots of things&lt;br /&gt;
&lt;br /&gt;
eBPF is meant for kernel introspection&lt;br /&gt;
 - what is happening when you make a system call or call a function?&lt;br /&gt;
&lt;br /&gt;
eBPF can look at kernel space, user space, and can move freely in between&lt;br /&gt;
&lt;br /&gt;
eBPF has lots of &amp;quot;ease of use&amp;quot; features to make this all surprisingly easy&lt;br /&gt;
  - still can be a bit complicated, we are dealing with an OS kernel!&lt;br /&gt;
&lt;br /&gt;
BPF stands for &amp;quot;Berkeley Packet Filter&amp;quot;&lt;br /&gt;
 - whenever you see &amp;quot;Berkeley&amp;quot; in the name of something related to UNIX, pay attention, it probably is important&lt;br /&gt;
 - while Bell Labs (AT&amp;amp;T) built UNIX initially, Berkeley (BSD UNIX) is where&lt;br /&gt;
   UNIX came onto the Internet (and basically built the Internet)&lt;br /&gt;
&lt;br /&gt;
BPF was designed to do efficient network packet filtering&lt;br /&gt;
 - problem: want to specify rules for what packets to capture&lt;br /&gt;
 - initial packet processing happens in the kernel&lt;br /&gt;
 - but we normally add functionality in processes&lt;br /&gt;
 - so, if we implemented rules in processes, we&amp;#039;d have the slowdown&lt;br /&gt;
   of constantly switching between user mode and supervisor mode, potentially&lt;br /&gt;
   on every packet&lt;br /&gt;
 - BPF solves this problem by allowing code to be loaded into the kernel&lt;br /&gt;
   for processing packets&lt;br /&gt;
&lt;br /&gt;
Internet is a network of networks&lt;br /&gt;
 - connecting networks like your home network to your ISP, or a&lt;br /&gt;
   departmental lab to the Carleton network&lt;br /&gt;
 - LOTS of technologies implementing these networks&lt;br /&gt;
   - ethernet, wifi, ATM, SONET, carrier pigeons...&lt;br /&gt;
 - so we need a way to send data that doesn&amp;#039;t depend on the technology&lt;br /&gt;
&lt;br /&gt;
Internet is built on a couple of insights&lt;br /&gt;
 - can divide communication into &amp;quot;packets&amp;quot; or &amp;quot;datagrams&amp;quot; with a maximum size&lt;br /&gt;
    - classically, 1500 bytes but this varies&lt;br /&gt;
 - each packet is like a postcard - you send it from somewhere to get to another place&lt;br /&gt;
 - each packet has a source address and a destination address, which are numbers&lt;br /&gt;
   (32 bits for IPv4, 128 bits for IPv6)&lt;br /&gt;
 - ideally, every device connected to the Internet has a unique address&lt;br /&gt;
   - messed this up with IPv4 with technologies such as NAT&lt;br /&gt;
 - so, all your computer does is send out packets with the IP addresses as desired destinations, and it receives packets where the destination IP address is its own&lt;br /&gt;
&lt;br /&gt;
 - other key insight: best effort delivery&lt;br /&gt;
   - anyone can corrupt or throw away (drop) a packet at any time for any reason)&lt;br /&gt;
 - we have to layer protocols on top of these packets to get reliable communication&lt;br /&gt;
&lt;br /&gt;
TCP/IP: IP is the base protocol, TCP is the most common protocol layered on it to produce continuous, reliable streams of bytes&lt;br /&gt;
&lt;br /&gt;
Networking is really why we all things that are UNIX-like or not too different (Windows).  Because we need a design that is good at handling network traffic at any time&lt;br /&gt;
&lt;br /&gt;
 - older systems without a privileged kernel used to crash all the time when&lt;br /&gt;
   put on the Internet (think Windows 3.1, MacOS 9 and before)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
BPF&lt;br /&gt;
 - need a way to load code into the kernel&lt;br /&gt;
 - should be safe&lt;br /&gt;
 - just needs to specify rules for handling network packets&lt;br /&gt;
&lt;br /&gt;
BPF solution: build a bytecode virtual machine with a verifier&lt;br /&gt;
 - bytecode: no direct access to memory, is compiled when loaded&lt;br /&gt;
 - verifier: check for funny business, make sure code always terminates&lt;br /&gt;
&lt;br /&gt;
eBPF is a Linux technology that extends BPF to allow for arbitrary kernel introspection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
exploiting the Linux kernel&lt;br /&gt;
 - modules are the way you do it normally, if you can load a module, game over&lt;br /&gt;
 &lt;br /&gt;
Rootkits&lt;br /&gt;
 - just modifications that allow an attacker to hide and maintain control&lt;br /&gt;
 - if they modify the kernel, they can hide in a way that no process can find you&lt;br /&gt;
&lt;br /&gt;
If you really want to protect a Linux system, disable modules and eBPF&lt;br /&gt;
 - but that makes things very inconvenient&lt;br /&gt;
 - signed modules are close&lt;br /&gt;
&lt;br /&gt;
CPU bugs (meltdown and spectre)&lt;br /&gt;
 - major security implications for any system that runs untrusted code&lt;br /&gt;
   (i.e., anything running a web browser)&lt;br /&gt;
 - problem is with hyperthreading - allowing multiple processes/threads to share a CPU at the same time&lt;br /&gt;
&lt;br /&gt;
Next lecture will be on *Monday*, no lecture on Wednesday. Will announce details on discord&lt;br /&gt;
&lt;br /&gt;
Friday lecture will be in the lecture hall live (but also livestreamed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>