<?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_2019W_Lecture_21</id>
	<title>Operating Systems 2019W Lecture 21 - 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_2019W_Lecture_21"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019W_Lecture_21&amp;action=history"/>
	<updated>2026-04-05T18:28:39Z</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_2019W_Lecture_21&amp;diff=22313&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  The video from the lecture given on April 1, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019w/lectures/comp3000-2019w-lec21-20190401.m4v is now available]....&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019W_Lecture_21&amp;diff=22313&amp;oldid=prev"/>
		<updated>2019-04-01T23:06:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  The video from the lecture given on April 1, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019w/lectures/comp3000-2019w-lec21-20190401.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;
The video from the lecture given on April 1, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019w/lectures/comp3000-2019w-lec21-20190401.m4v is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 21&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
A4 Quiz coming out Sunday night, substitue for A4 submission&lt;br /&gt;
 - you can still submit A4, but it won&amp;#039;t be graded unless you ask for it to because you don&amp;#039;t think your answers to the multiple choice questions matches your understanding of the material.  Likely the grading will be in an in-person meeting.&lt;br /&gt;
&lt;br /&gt;
Fine-grained access control&lt;br /&gt;
---------------------------&lt;br /&gt;
(and alternative ways of doing access control)&lt;br /&gt;
&lt;br /&gt;
When you run with privileges, drop them as soon as you can&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;re in a setuid root context, you can drop privileges by&lt;br /&gt;
running seteuid(), change it to process&amp;#039;s real UID&lt;br /&gt;
&lt;br /&gt;
assume uid=1000, euid=0&lt;br /&gt;
if you run seteuid(1000), then uid=1000, euid=1000&lt;br /&gt;
&lt;br /&gt;
but&lt;br /&gt;
&lt;br /&gt;
you can still run seteuid(0) after doing this!&lt;br /&gt;
 - so only worth doing if you know attacker can&amp;#039;t take control&lt;br /&gt;
   of code (e.g., no code injection vulnerabilities)&lt;br /&gt;
&lt;br /&gt;
You can make the euid change permanent if you then do an execve&lt;br /&gt;
&lt;br /&gt;
But still, this is very coarse - you either can do everything or you can&lt;br /&gt;
do almost nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ideally you&amp;#039;d like to split up the powers of root into subsets&lt;br /&gt;
 - so you&amp;#039;d only keep the privileges you need&lt;br /&gt;
&lt;br /&gt;
Well, what can root do?&lt;br /&gt;
 - access any file&lt;br /&gt;
 - mount/unmount filesystems&lt;br /&gt;
 - allocate low-numbered ports (&amp;lt;1024)&lt;br /&gt;
    http  80&lt;br /&gt;
    https 443&lt;br /&gt;
    ssh   22&lt;br /&gt;
    smtp  25&lt;br /&gt;
    auth smtp 465&lt;br /&gt;
 - configure networks&lt;br /&gt;
 - access block devices&lt;br /&gt;
 - set the time&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
Linux kernel capabilities allow you to control whether a process can or&lt;br /&gt;
cannot do different kinds of privileged operations&lt;br /&gt;
 - normally a process starts as roots and then drops capabilities it doesn&amp;#039;t need&lt;br /&gt;
 - but you can be &amp;quot;setuid&amp;quot; for capabilities using extended attributes&lt;br /&gt;
   (on some filesystems)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why dow we want fine-grained access control?  Is it really better?&lt;br /&gt;
 - well, it limits damage when an attacker gets control&lt;br /&gt;
 - but it makes the jobs of developers, users, and admins harder&lt;br /&gt;
&lt;br /&gt;
SELinux allows for very fine-grained access control (and more)&lt;br /&gt;
 - but mostly people want to disable it, because they don&amp;#039;t understand it&lt;br /&gt;
&lt;br /&gt;
Android permissions&lt;br /&gt;
 - fine grained in a mostly useless way&lt;br /&gt;
&lt;br /&gt;
Nowadays we do more sandboxing rather than fine-grained access control&lt;br /&gt;
 - default deny, limited flexibility rather than arbitrary flexibility&lt;br /&gt;
&lt;br /&gt;
Discretionary versus mandatory access control (DAC vs MAC)&lt;br /&gt;
 - discretionary: can change at runtime&lt;br /&gt;
 - mandatory: *cannot* change at runtime, must reboot into special mode&lt;br /&gt;
&lt;br /&gt;
MAC limits the power of root&lt;br /&gt;
 - root can&amp;#039;t change the policies at runtime&lt;br /&gt;
 - useful at times but can be very very painful to use, thus&lt;br /&gt;
   most common question about systems like SELinux is how to disable it&lt;br /&gt;
&lt;br /&gt;
Sandboxing&lt;br /&gt;
 - not a technology, more a hope or goal&lt;br /&gt;
&lt;br /&gt;
a sandbox is an environment for running programs in which the program stays isolated from the outside world (except for &amp;quot;safe&amp;quot; connections)&lt;br /&gt;
 - so it is safe to run untrusted code inside of a sandbox&lt;br /&gt;
&lt;br /&gt;
Since more and more code isn&amp;#039;t trusted, sandoxes show up everywhere&lt;br /&gt;
&lt;br /&gt;
A process itself is a kind of sandbox - but a very very leaky one&lt;br /&gt;
&lt;br /&gt;
processes have lots of shared state&lt;br /&gt;
 - filesystem&lt;br /&gt;
 - process list/signals&lt;br /&gt;
 - IPC of all kinds&lt;br /&gt;
&lt;br /&gt;
How do you &amp;quot;sandbox&amp;quot; a program?&lt;br /&gt;
 A add restrictions to processes&lt;br /&gt;
 B add restrictions to the OS&lt;br /&gt;
 C implement a &amp;quot;virtual machine&amp;quot; of some kind, run it in there&lt;br /&gt;
   (using a language that the native machine can&amp;#039;t run directly)&lt;br /&gt;
   &lt;br /&gt;
A is containers &amp;lt;-- hacks on the OS&lt;br /&gt;
B is hardware virtual machines (VMWare, kvm, etc) &amp;lt;-- isolate the OS&lt;br /&gt;
C is Java and JavaScript&lt;br /&gt;
&lt;br /&gt;
C can provide the strongest guarantees but has considerable complexity&lt;br /&gt;
B is very heavyweight (new kernel per isolated instance)&lt;br /&gt;
A is fashionable and not so good&lt;br /&gt;
&lt;br /&gt;
Containers allow a kernel to run multiple, separate userlands&lt;br /&gt;
 - potentially each with its own set of users including root and&lt;br /&gt;
   its own filesystem structure&lt;br /&gt;
&lt;br /&gt;
WebAssembly&lt;br /&gt;
&lt;br /&gt;
First, there was the JavaScript sandbox&lt;br /&gt;
 - limited capabilities (no background processing, no filesystem access,&lt;br /&gt;
   very limited network access)&lt;br /&gt;
 - then came AJAX  (or just AJ now), so JavaScript became more powerful&lt;br /&gt;
 - got full apps in JavaScript, so runtimes had to get faster&lt;br /&gt;
 - V8 was so good, was moved to the server (node.js)&lt;br /&gt;
&lt;br /&gt;
Javascript is everywhere, is fast, can do sandboxing, but not everyone likes it&lt;br /&gt;
&lt;br /&gt;
Emscripten came along - allow you to compile arbitrary languages to Javascript&lt;br /&gt;
&lt;br /&gt;
Mozilla came up with asm.js - subset of JS as a target for Emscripten&lt;br /&gt;
&lt;br /&gt;
Google came up with NaCl - native client, subset of x86 for browsers&lt;br /&gt;
&lt;br /&gt;
asm.js + NaCL =&amp;gt; WebAssembly&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>