<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aleksp</id>
	<title>Soma-notes - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aleksp"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php/Special:Contributions/Aleksp"/>
	<updated>2026-06-02T19:43:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_23&amp;diff=21377</id>
		<title>Operating Systems 2017F Lecture 23</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_23&amp;diff=21377"/>
		<updated>2017-12-09T16:16:33Z</updated>

		<summary type="html">&lt;p&gt;Aleksp: /* Additional Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
[http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec23-07Dec2017.mp4 Lecture 23 Video]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
===In Class===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 23&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
How can you tell when a process has been compromised?&lt;br /&gt;
 - from outside the process&lt;br /&gt;
&lt;br /&gt;
Classic: signatures&lt;br /&gt;
 - is it running &amp;quot;bad code&amp;quot;&lt;br /&gt;
 - is it doing &amp;quot;bad things&amp;quot;&lt;br /&gt;
   - bad system calls&lt;br /&gt;
&lt;br /&gt;
For a process to do damage, it has to make &amp;quot;bad&amp;quot; system calls&lt;br /&gt;
&lt;br /&gt;
How can I tell if a process is making bad system calls?&lt;br /&gt;
&lt;br /&gt;
I want to be lazy&lt;br /&gt;
 - complex rules are a pain&lt;br /&gt;
 - and, they don&#039;t work well either&lt;br /&gt;
&lt;br /&gt;
Make the computer solve the problem for me of determining what is good and bad&lt;br /&gt;
 - use machine learning&lt;br /&gt;
&lt;br /&gt;
But I can&#039;t teach good versus bad because I don&#039;t know bad very well&lt;br /&gt;
&lt;br /&gt;
But...I do know how systems &amp;quot;normally&amp;quot; behave&lt;br /&gt;
&lt;br /&gt;
How about teaching the system to differentiate normal from abnormal?&lt;br /&gt;
 - normal is &amp;quot;good&amp;quot;&lt;br /&gt;
 - abnormal may be bad&lt;br /&gt;
&lt;br /&gt;
abnormal but not bad =&amp;gt; false positive&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How do we detect abnormal system calls?&lt;br /&gt;
&lt;br /&gt;
Learn normal patterns of system calls over time&lt;br /&gt;
once you&#039;ve learned enough, watch for abnormal system calls&lt;br /&gt;
&lt;br /&gt;
Since I&#039;m lazy, I want it to learn as it runs&lt;br /&gt;
 - and automatically decide when it has learned enough&lt;br /&gt;
&lt;br /&gt;
Could I do the learning in a process (or set of processes)?&lt;br /&gt;
 - you could, but all data would have to come from the kernel&lt;br /&gt;
&lt;br /&gt;
Want something fast and simple&lt;br /&gt;
 - implement in the kernel&lt;br /&gt;
&lt;br /&gt;
How simple could it be?&lt;br /&gt;
&lt;br /&gt;
First assumption: ignore arguments&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Second assumption: look at ordering of systems calls on a per-thread, per-process basis&lt;br /&gt;
&lt;br /&gt;
Third assumption: characterize processes based on the executable they are running&lt;br /&gt;
&lt;br /&gt;
 - model per executable, each trained on multiple processes&lt;br /&gt;
&lt;br /&gt;
How to model the trace of system calls coming from a process?&lt;br /&gt;
&lt;br /&gt;
* frequency analysis?&lt;br /&gt;
  - on a system call basis&lt;br /&gt;
  - high variance&lt;br /&gt;
&lt;br /&gt;
* what system calls are made (and not made)?&lt;br /&gt;
&lt;br /&gt;
* short sequences of system calls?&lt;br /&gt;
  6-10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Additional Notes===&lt;br /&gt;
Written solutions for midterm exam are on the course webpage &amp;lt;br&amp;gt;&lt;br /&gt;
Assignment 4 &amp;lt;br&amp;gt;&lt;br /&gt;
Q2: SSH keygen generates the secret key and the public key file. The private key is stored in the private key file: .ssh/id_rsa  &amp;lt;br&amp;gt;&lt;br /&gt;
Q4: Both lines because first you start from 1 and then increment from there. &amp;lt;br&amp;gt;&lt;br /&gt;
Q11: Only bs because it is write. Would be ibs and bs if it was read. &amp;lt;br&amp;gt;&lt;br /&gt;
Q12: Local kernel forwards the write system call but doesn&#039;t actually make the system call. Kernels don&#039;t make system calls.&amp;lt;br&amp;gt;&lt;br /&gt;
Lecture 23 Prof Notes &amp;lt;br&amp;gt;&lt;br /&gt;
-----------------&lt;br /&gt;
How can you tell when a process has been compromised. &amp;lt;br&amp;gt;&lt;br /&gt;
- from outside the process &amp;lt;br&amp;gt;&lt;br /&gt;
Use signatures &amp;lt;br&amp;gt;&lt;br /&gt;
- is it running &amp;quot;bad code&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
- is it doing &amp;quot;bad things&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
-- For example: password program start modifying files other than etc/password. You could specify rules to prevent this. &amp;lt;br&amp;gt;&lt;br /&gt;
-- bad system calls&amp;lt;br&amp;gt;&lt;br /&gt;
For a process to do damage, it has to make &amp;quot;bad&amp;quot; system calls &amp;lt;br&amp;gt;&lt;br /&gt;
I want to be lazy &amp;lt;br&amp;gt;&lt;br /&gt;
- complex rules are a pain &amp;lt;br&amp;gt; &lt;br /&gt;
- and they don&#039;t work well either &amp;lt;br&amp;gt; &lt;br /&gt;
Make the computer solve this problem &amp;lt;br&amp;gt;&lt;br /&gt;
- Use Machine Learning &amp;lt;br&amp;gt;&lt;br /&gt;
I can&#039;t teach good versus bad if I don&#039;t know what is bad &amp;lt;br&amp;gt;&lt;br /&gt;
But I know how systems behave normally &amp;lt;br&amp;gt;&lt;br /&gt;
How about teaching the system to differentiate normal from abnormal &amp;lt;br&amp;gt;&lt;br /&gt;
- normal is good &amp;lt;br&amp;gt;&lt;br /&gt;
- abnormal may be bad &amp;lt;br&amp;gt;&lt;br /&gt;
abnormal but not bad =&amp;gt; false positive &amp;lt;br&amp;gt;&lt;br /&gt;
False positives can be a big issue because they may cause ppl to not trust the machine&#039;s detection capabilities &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How can we detect abnormal system calls? &amp;lt;br&amp;gt;&lt;br /&gt;
Learn normal patterns of system calls over time &amp;lt;br&amp;gt;&lt;br /&gt;
Once you&#039;ve learned enough, watch for abnormal system calls &amp;lt;br&amp;gt;&lt;br /&gt;
Since I&#039;m lazy, I want to learn it as it runs &amp;lt;br&amp;gt;&lt;br /&gt;
- and automatically decide when it has learned enough &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Could I do the learning in a process (or set of processes)? &amp;lt;br&amp;gt;&lt;br /&gt;
you could, but all data would have to come from the kernel &amp;lt;br&amp;gt;&lt;br /&gt;
Want something fast and simple &amp;lt;br&amp;gt;&lt;br /&gt;
- implement in the kernel &amp;lt;br&amp;gt; &lt;br /&gt;
How simple could it be? &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First assumption: ignore arguments &amp;lt;br&amp;gt;&lt;br /&gt;
Second assumption: look at ordering of system calls on a per-thread, per-process basis &amp;lt;br&amp;gt;&lt;br /&gt;
Third Assumption: characterize processes based on the executable they are running &amp;lt;br&amp;gt;&lt;br /&gt;
model per executable, each trained on multiple processes &amp;lt;br&amp;gt;&lt;br /&gt;
How to model the trace of system calls coming from a procesd &amp;lt;br&amp;gt;&lt;br /&gt;
* frequency analysis? &amp;lt;br&amp;gt;&lt;br /&gt;
- on a system call basis &amp;lt;br&amp;gt;&lt;br /&gt;
- high variance &amp;lt;br&amp;gt;&lt;br /&gt;
* what system calls are made (and not made)? &amp;lt;br&amp;gt;&lt;br /&gt;
* short sequence of system calls? 6-10 calls &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Lecture 23&lt;br /&gt;
&lt;br /&gt;
How can you tell a process has been compromised (i.e. from outside the process)?&lt;br /&gt;
* The process is working on behalf of an attacker&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Classic way to do this: &lt;br /&gt;
* Pattern matching -&amp;gt; signatures&lt;br /&gt;
::* is the process running bad code?&lt;br /&gt;
::* is the process doing bad things?&lt;br /&gt;
:::* i.e. /etc/passwd -&amp;gt; password prog. should only be able to access it&lt;br /&gt;
:::* if a process is going to do bad things, it&#039;s going to make &amp;quot;bad&amp;quot; system calls&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
So, how can we tell if a process is making bad system calls?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t want to sit and write complex rules to determine:&lt;br /&gt;
* Which programs should make which system calls, etc.&lt;br /&gt;
::* i.e. policy based systems and sandboxing of processes&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Therefore, we want the computer to determine what call is good/bad.&lt;br /&gt;
* i.e. use machine learning&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The issue is, we have to demonstrate, not just &amp;quot;good&amp;quot;, but also &amp;quot;bad&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
We have lots of examples of &amp;quot;bad&amp;quot;, but is not necessarily representative of &amp;quot;bad&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
Difficult to enumerate all possible occurences of &amp;quot;bad&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
However, we know how systems &amp;quot;normally&amp;quot; behave&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How about teaching the system to differentiate normal from abnormal?&lt;br /&gt;
* Assume:&lt;br /&gt;
::* normal is &amp;quot;good&amp;quot;&lt;br /&gt;
::* abnormal may be bad&lt;br /&gt;
:::* there is no guarantee that abnormal is bad, however, if it&#039;s bad, but not abnormal... we&#039;re in trouble&lt;br /&gt;
:::* false positives are bad (i.e. abnormal but not good)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How do we detect abnormal system calls?&lt;br /&gt;
* a machine learning problem&lt;br /&gt;
* the system should learn as it runs and decide when it has learned &amp;quot;enough&amp;quot;&lt;br /&gt;
::* learn normal patterns of system calls over time&lt;br /&gt;
:::* once learned enough, watch for abnormal system calls&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Could we do the learning within processes?&lt;br /&gt;
* possible, but all data would have to come from the kernel&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Want something fast and simple, so it can be implemented in the kernel&lt;br /&gt;
* you&#039;re right at ground-level, where decisions are being made&lt;br /&gt;
::* i.e. if bad system call being made -&amp;gt; can stop it immediatelly&lt;br /&gt;
&lt;br /&gt;
* don&#039;t want to be training a neural network to do this -&amp;gt; too complicated, too much overhead&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;Thu 7 Dec 2017 13:53:01 EST -&amp;gt; Video of observing system calls, ls vs. xclock&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== First assumption: ===&lt;br /&gt;
ignore the arguments system calls are making -&amp;gt; look at the calls themselves&lt;br /&gt;
* but, different processes invoke different calls -&amp;gt; how to compare them?&lt;br /&gt;
* even multi-threaded processes will mirror the structure of the code in the calls it makes&lt;br /&gt;
&lt;br /&gt;
=== Second assumption: ===&lt;br /&gt;
look at the ordering of system calls on a per-thread, per-process basis&lt;br /&gt;
* doesn&#039;t make sense to think of &#039;ls&#039; system calls in the context of &#039;xclock&#039; system calls&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Therefore, any profiling will be based on the code being executed&lt;br /&gt;
&lt;br /&gt;
=== Third assumption: ===&lt;br /&gt;
characterize processes based on the executable they are running&lt;br /&gt;
* model per executable, with each one trained on multiple processes&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How do we model the trace of system calls coming from a process?&lt;br /&gt;
* How often do different system calls hapen? -&amp;gt; frequency analysis&lt;br /&gt;
* high variance -&amp;gt; the calls change frequently&lt;br /&gt;
::* i.e. ls of a large dir vs. small dir&lt;br /&gt;
&lt;br /&gt;
::* What system calls does a process makes or doesn&#039;t make?&lt;br /&gt;
&lt;br /&gt;
::* Rather than examining if a process does or doesn&#039;t make a particular system call, instead look at short sequences of system calls being made.&lt;br /&gt;
:::* What is the variation in the pattern of sequences of calls being made? A compromised program will be detectable.&lt;br /&gt;
&lt;br /&gt;
:::* Table lookup of sequences made by a program and compare against new sequences&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How short is a short sequence of system calls? -&amp;gt; 6 to 10&lt;br /&gt;
&lt;br /&gt;
When a program is running, the short sequences define the control flow path of the program&amp;lt;br&amp;gt;&lt;br /&gt;
The short sequences together represent the control flow&amp;lt;br&amp;gt;&lt;br /&gt;
When a program is exploited, an abnormal control flow, an uncommon path, is being used&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Try the simple hack first, rather than designing/engineering a complex solution&lt;br /&gt;
* the simple hack will often present valuable insights&lt;/div&gt;</summary>
		<author><name>Aleksp</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_19&amp;diff=21360</id>
		<title>Operating Systems 2017F Lecture 19</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_19&amp;diff=21360"/>
		<updated>2017-12-07T17:20:06Z</updated>

		<summary type="html">&lt;p&gt;Aleksp: /* Additional Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
[http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec19-21Nov2017.mp4]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
===In Class===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 19&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
Where&#039;s main?&lt;br /&gt;
&lt;br /&gt;
* lots of programs have &amp;quot;main&amp;quot; functions - a function that runs first and controls the execution of the program&lt;br /&gt;
* Do these have &amp;quot;main&amp;quot; functions? In what sense?&lt;br /&gt;
  - Linux kernel modules&lt;br /&gt;
  - FUSE applications?&lt;br /&gt;
  - the Linux kernel?&lt;br /&gt;
  - node web applications?&lt;br /&gt;
&lt;br /&gt;
In many systems, &amp;quot;main&amp;quot; just sets up event handlers&lt;br /&gt;
 - the event loop can be implicit or explicit&lt;br /&gt;
   - or there may be no loop at all, just handlers and &amp;quot;interrupts&amp;quot; of some kind&lt;br /&gt;
 - event loops poll (check) to see when there are new events&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
OS kernels are essentially the same thing&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional Notes:&lt;br /&gt;
&lt;br /&gt;
Important notes:&lt;br /&gt;
How can you recover a filesystem?&lt;br /&gt;
How do you delete a file?&lt;br /&gt;
What is a filesystem?: &lt;br /&gt;
*persistent data structure &lt;br /&gt;
* stored in fixed-sized blocks (at least 512 bytes in size)&lt;br /&gt;
*maps hierarchical filenames to file contents &lt;br /&gt;
*has metadata about files (somwhow)&lt;br /&gt;
What is in a filesystem?&lt;br /&gt;
*data blocks &lt;br /&gt;
*metadata blocks &lt;br /&gt;
How do you organize metdata:&lt;br /&gt;
1)	First you must identify characteristics of the file system &lt;br /&gt;
Superblock :  summary y block which tells you about the other blocks you have and it depends on which file system you have. It’s usually the first block of a file system. &lt;br /&gt;
In the superblock? :&lt;br /&gt;
1)	What kind of file system is this? By checking what is the magic number it has &lt;br /&gt;
2)	How big is the file system?&lt;br /&gt;
3)	How is it organized?&lt;br /&gt;
4)	Where can I find the rest of the metadata?&lt;br /&gt;
&lt;br /&gt;
*How can you identify which file system it is from looking at the super class&lt;br /&gt;
-&amp;gt; google “magic number of a file” &lt;br /&gt;
-&amp;gt; ex: jpg ctr^c ctr^c : switched the pictures into a binary file &lt;br /&gt;
-&amp;gt; look at the beginning of the file you will see JFIF:  first several bytes in general that identifies the type of the file (magic number)&lt;br /&gt;
File extension : &lt;br /&gt;
	what is it ? &lt;br /&gt;
	is it important&lt;br /&gt;
	the kernel does not know and not care about it&lt;br /&gt;
&lt;br /&gt;
For POSIX file systems: &lt;br /&gt;
-.&amp;gt; file metadata is stored in inodes &lt;br /&gt;
-.&amp;gt; most have pre-reserved inodes &lt;br /&gt;
   -&amp;gt; the only way you can run out of inodes if you keep creating small files &lt;br /&gt;
&lt;br /&gt;
Usenet : al the things you use to post messages thro social media, email, etc. Those were made using Usenet. Like email but Local Usenet server. But it died over time. Every message is stored in an individual file. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Important commands: &lt;br /&gt;
File * : to identify the kind of file system&lt;br /&gt;
1.	As : Run dumpe2fs foo. What does the output of this command mean?&lt;br /&gt;
	Does this give you info about the file system?&lt;br /&gt;
	File bar : bar is the file name and cp comp3000-midterm-2017.pdf bar &lt;br /&gt;
	Evince bar : opens up the pdf file&lt;br /&gt;
&lt;br /&gt;
=== Additional Notes ===&lt;br /&gt;
&lt;br /&gt;
Where&#039;s main?&lt;br /&gt;
* lots of program shave &amp;quot;main&amp;quot; functions - a function that runs first and controls the execution of the program&amp;lt;br&amp;gt;&lt;br /&gt;
* Do these have &amp;quot;main&amp;quot; functions?&amp;lt;br&amp;gt;&lt;br /&gt;
** Linux kernel modules&amp;lt;br&amp;gt;&lt;br /&gt;
** FUSE applications?&amp;lt;br&amp;gt;&lt;br /&gt;
** the linux kernel?&amp;lt;br&amp;gt;&lt;br /&gt;
** node web applications?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In many systems, &amp;quot;main&amp;quot; just sets up even handlers&amp;lt;br&amp;gt;&lt;br /&gt;
* the event loop can be implicit or explicit&amp;lt;br&amp;gt;&lt;br /&gt;
** or there may be no loop at all, just handlers and &amp;quot;interrupts&amp;quot; some kind&amp;lt;br&amp;gt;&lt;br /&gt;
* event loops poll (check) to see when there are new events&amp;lt;br&amp;gt;&lt;br /&gt;
* what are event loops for node app?&amp;lt;br&amp;gt;&lt;br /&gt;
** where are interrupts for node apps? &amp;lt;br&amp;gt;&lt;br /&gt;
***Incoming network requests, it&#039;s an event&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Code run differently in the kernel : &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1)functions runs on the bhealf of insmod, unles sit is Independence context &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2)codes that run on the bhelaf o the process&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3)after an interrupt: no process , it is an interrupt cotext &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) file names : regular programs but the square brackets, execution context + address space. they share the kernel&#039;s address space, they are called kernel threads which are independently scheduling . You can not kill them but you can change their scheduling , maybe their priority but not 100%. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
does it create a proces? no , but it can create a kernel thread (is it a process? virtual adress space, .&amp;lt;br&amp;gt;&lt;br /&gt;
multi- threaded: maintains multiple address processes , ex: fire fox. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ps -elF | less &amp;quot;number&amp;quot; : displays threads.&lt;br /&gt;
&lt;br /&gt;
top : displays all the processes &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ls time : shows you the time . &lt;br /&gt;
&lt;br /&gt;
sys: how much time in the kernel space&lt;br /&gt;
real: how much time &lt;br /&gt;
user : how much time in user space &lt;br /&gt;
&lt;br /&gt;
process : can&#039;t manipulate its own memory map directly, it has an address space, but cant change it. Process: is limited but the kernel is not and the kernel can change it&#039;s own address and in charge of its self. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kernel tasks : are threads, when a process makes a system call , thi sis schedules in the process priority. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When running &amp;lt;br&amp;gt; &lt;br /&gt;
&amp;quot;time ls&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
real = realtime it took to run&lt;br /&gt;
user = the user space time&lt;br /&gt;
sys = kernel time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What&#039;s flow of control in tutorial 7? &amp;lt;br&amp;gt;&lt;br /&gt;
What is the connection? &amp;lt;br&amp;gt;&lt;br /&gt;
To exit the program, we must unmount the filesystem, run &amp;quot;sudo umount mnt&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
OS kernels are essentially the same thing&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
what is the flow of control ? what connection between things we are doing in the new terminal and the old one&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; these programs are communicating to each other, it will be invoked when we use mnt (mount) the kernel knows it is a filesystem , process runs system calls, then kernel talks to out original terminal. How? you can use strace to know, it is waiting to be invoked, to receive and responds to messages. events will be passed off to another process. switching between one process to another. it has potential security benefits. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Key to understand this tutorial : &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; understand net flow control. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; how do processes communicate?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; how does it take a directory int and creates a filesystem from it?: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
***sub tree starting at mount is delegated to this process.&amp;lt;br&amp;gt; &lt;br /&gt;
***permissions are limited &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to kill it?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; ctrl c , no , you can but the kernel will be unhappy.&amp;lt;br&amp;gt;&lt;br /&gt;
-&amp;gt; unmount the file system when you are done using it &amp;lt;br&amp;gt;&lt;br /&gt;
-&amp;gt; umount / you have to do it as root &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Node web applications &amp;lt;br&amp;gt;&lt;br /&gt;
* Theres not a dedicated main function but its the first thing that runs &amp;lt;br&amp;gt;&lt;br /&gt;
* Every line in the node application terminates &amp;lt;br&amp;gt;&lt;br /&gt;
* If you start a web server, the function call starting it will terminate &amp;lt;br&amp;gt;&lt;br /&gt;
* Whats running? The main has finished. Is the program doing anything actively if theres no external input? &amp;lt;br&amp;gt;&lt;br /&gt;
* In many systems main just sets up event handlers &amp;lt;br&amp;gt;&lt;br /&gt;
* The event loop can be implicit or explicit &amp;lt;br&amp;gt;&lt;br /&gt;
* Its possible to have no loop at all just handlers and interrupts of some kind &amp;lt;br&amp;gt;&lt;br /&gt;
* Event loops check to see when there are new events &amp;lt;br&amp;gt;&lt;br /&gt;
* Os kernels behave the same way as node applications &amp;lt;br&amp;gt;&lt;br /&gt;
* Waiting for events &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens when you use insmod? &amp;lt;br&amp;gt;&lt;br /&gt;
* In newgetpid: Init and exit are called when the insmod program makes system calls to load the module &amp;lt;br&amp;gt;&lt;br /&gt;
* Init is run on behalf on insmod &amp;lt;br&amp;gt;&lt;br /&gt;
* Kernel code fits into 3 categories &amp;lt;br&amp;gt;&lt;br /&gt;
** Code that runs on behalf of a process &amp;lt;br&amp;gt;&lt;br /&gt;
** Code that runs after an interrupt &amp;lt;br&amp;gt;&lt;br /&gt;
** Kernel threads, has lots of functionality &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Why is a kernel thread not a process? &amp;lt;br&amp;gt;&lt;br /&gt;
* The kernel maintains its own address space &amp;lt;br&amp;gt;&lt;br /&gt;
* Has its own virtual address map &amp;lt;br&amp;gt;&lt;br /&gt;
* The kernel always has just 1 address space regardless of how many threads there are &amp;lt;br&amp;gt;&lt;br /&gt;
* Processes cannot manipulate its own memory map directly, needs to ask kernel first &amp;lt;br&amp;gt;&lt;br /&gt;
* Processes are limited, the kernel is not, has control over itself &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Kernel tasks = kernel threads &amp;lt;br&amp;gt;&lt;br /&gt;
* Independently scheduled &amp;lt;br&amp;gt;&lt;br /&gt;
* Once we call insmod everything happens in user space &amp;lt;br&amp;gt;&lt;br /&gt;
* Strace uses a system call called ptrace &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tutorial 7: Fuse &amp;lt;br&amp;gt;&lt;br /&gt;
* Memoryll.py program &amp;lt;br&amp;gt;&lt;br /&gt;
* Always unmount a filesystem when youre done using it &amp;lt;br&amp;gt;&lt;br /&gt;
*No class Thursday! no office hours on Wednesday&lt;br /&gt;
&lt;br /&gt;
=== Lecture 19 ===&lt;br /&gt;
&lt;br /&gt;
==== Where&#039;s main? ====&lt;br /&gt;
&lt;br /&gt;
* lots of programs have &amp;quot;main&amp;quot; functions - a function that runs first and controls the execution of the program&lt;br /&gt;
* do these have &amp;quot;main&amp;quot; functions?&lt;br /&gt;
:* Linux kernel modules?&lt;br /&gt;
:* FUSE applications?&lt;br /&gt;
:* the Linux kernel?&lt;br /&gt;
:* node web applications?&lt;br /&gt;
&lt;br /&gt;
===== In many systems, &amp;quot;main&amp;quot; just sets up event handlers =====&lt;br /&gt;
* the event loop can be implicit or explicit&lt;br /&gt;
:* or there may be no loop at all, just handlers and &amp;quot;interrupts&amp;quot; of some kind&lt;br /&gt;
* event loops poll (check) to see when there are new events&lt;br /&gt;
&lt;br /&gt;
===== OS kernels are essentially the same thing -&amp;gt; just sitting around waiting for an event =====&lt;br /&gt;
* when an event happens -&amp;gt; do something&lt;br /&gt;
* in this case events = interrupts, generally&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
::* insmod exec. is execve(), new binary, makes system calls to load new module &lt;br /&gt;
::* init, called when insmod makes systemcalls to load new module &lt;br /&gt;
::* as part of loading a module, run the function that makes the necessary system calls &lt;br /&gt;
::* see static int __init newgetpid_init(void) -&amp;gt; soma notes &lt;br /&gt;
::* there is no process... it&#039;s an interrupt context  --&amp;gt; check in context of assignment &lt;br /&gt;
::* the kernel maintains its own address space for all kernel operations... it has its own virtual address map... every process has its own address space, which is created every time a process is created &lt;br /&gt;
::* try stracing insmod to see what system calls are being made (Openbox, not on live system) &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Tut 7 ====&lt;br /&gt;
* if you make a new directory inside /mnt it doesn&#039;t affect it&lt;br /&gt;
:* what&#039;s the control flow here?&lt;br /&gt;
:* program running is a kernel interface talking to another kernel interface&lt;br /&gt;
:* kernel is handing off anything that happens in /mnt to the running python process&lt;br /&gt;
:* the kernel talks to the new filesystem in ../../../mnt, which is waiting for events (waiting to be invoked)&lt;br /&gt;
::* classic microkernel architecture&lt;br /&gt;
&lt;br /&gt;
* understand the flow of control... what is the kernel doing?&lt;br /&gt;
* what does it mean to have a filesystem implemented&lt;/div&gt;</summary>
		<author><name>Aleksp</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_20&amp;diff=21357</id>
		<title>Operating Systems 2017F Lecture 20</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_20&amp;diff=21357"/>
		<updated>2017-12-07T17:09:47Z</updated>

		<summary type="html">&lt;p&gt;Aleksp: /* Additional Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
[http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec20-28Nov2017.mp4 Class Video]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
===In Class===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 20&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
When we run &amp;quot;ls&amp;quot; on an sshfs-mounted filesystem&lt;br /&gt;
* ls makes system calls (open, getdents) to the local Linux kernel&lt;br /&gt;
* the local kernel sees filesystem is FUSE, calls FUSE routines for open, getdents (via vfs abstraction)&lt;br /&gt;
* FUSE calls the sshfs process that mounted the filesystem&lt;br /&gt;
* sshfs process sends request to remote system&lt;br /&gt;
  - via socket system calls&lt;br /&gt;
* remote sshd process receives request (via system calls)&lt;br /&gt;
* remote sshd process accesses local filesystem&lt;br /&gt;
  - makes open, getdents system calls&lt;br /&gt;
  - remote kernel checks vfs, calls ext4 routines to access data&lt;br /&gt;
* remote sshd process responds to request (via system calls)&lt;br /&gt;
* local sshfs process receives response (via system calls)&lt;br /&gt;
* local sshfs process responds to FUSE request&lt;br /&gt;
* FUSE passes data back to vfs layer, then back to requesting process&lt;br /&gt;
&lt;br /&gt;
Normal file access permission check&lt;br /&gt;
 - compare uid, gid of file with uid, gid of process&lt;br /&gt;
&lt;br /&gt;
But really...&lt;br /&gt;
 - compares it with fsuid, fsgid of process&lt;br /&gt;
    - which is normally same as euid, egid of process&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Notes===&lt;br /&gt;
&lt;br /&gt;
Assignment 4 will be autograded and in fill in the blank form. This will not be like the final exam. &amp;lt;br&amp;gt;&lt;br /&gt;
You should think about who is doing what?  Otherwise FUSE won&#039;t make much sense &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Inode numbers completely changed when you use ssh. It starts with 1 from &amp;quot;.&amp;quot; (root) and increments from there. &amp;lt;br&amp;gt;&lt;br /&gt;
Inodes come from filesystem you are acessing &amp;lt;br&amp;gt;&lt;br /&gt;
He used df to find filesystem info &amp;lt;br&amp;gt;&lt;br /&gt;
The used Commands: mount | grep ubuntu and mount | grep vda1 to find type of filesystem &amp;lt;br&amp;gt;&lt;br /&gt;
In the SSH there is the filesystem type &amp;quot;fuse.sshfs&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
When you run strace on ls on the two terminals (ssh connection and the local one) you see similar output &amp;lt;br&amp;gt;&lt;br /&gt;
When we run &amp;quot;ls&amp;quot; on an ssh-mounted filesystem &amp;lt;br&amp;gt;&lt;br /&gt;
* ls makes system calls (open, getdents) to the local Linux kernel &amp;lt;br&amp;gt;&lt;br /&gt;
* the local kernel sees the filesystem is FUSE, calls DUSE routines for open, getdents (via vfs abstraction) &amp;lt;br&amp;gt;&lt;br /&gt;
* FUSE calls the sshfs process that mounted the filesystem&amp;lt;br&amp;gt;&lt;br /&gt;
* sshfs process sends request to remote system &amp;lt;br&amp;gt;&lt;br /&gt;
- via socket system calls&amp;lt;br&amp;gt;&lt;br /&gt;
* remote sshd process receives request (via system calls) &amp;lt;br&amp;gt;&lt;br /&gt;
* remote sshd process receives requests (via system calls)&amp;lt;br&amp;gt;&lt;br /&gt;
- makes open, getdents sytem calls &amp;lt;br&amp;gt;&lt;br /&gt;
- rmeote kernel checks vfs, calls ext4 routines to access data &amp;lt;br&amp;gt;&lt;br /&gt;
* remote sshd process responds to requests  (via system calls) &amp;lt;br&amp;gt;&lt;br /&gt;
* local sshfs process receives response  (via system calls) &amp;lt;br&amp;gt;&lt;br /&gt;
* local sshfs process responds to FUSE request  (via system calls)&amp;lt;br&amp;gt;&lt;br /&gt;
* FUSE passes data back to vfs layer, then back to requesting process &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; If you look as lsmod | less you see a ton of modules. Some of the modules are not necessary to mount the root filesystem.&amp;lt;br&amp;gt;&lt;br /&gt;
ls /lib/modules there are directories that store the kernel modules &amp;lt;br&amp;gt;&lt;br /&gt;
You have to have a filesystem that you mount initially that has a bunch of modules in it. Thus, there is an initial root file system that is necessary to load everything else &amp;lt;br&amp;gt;&lt;br /&gt;
This is the initial RAM disk. This filesystem loads the modules needed for the real filesystem. &amp;lt;br&amp;gt;&lt;br /&gt;
To remove a file I need to remove the hardlink from the directory where the hardlink exists &amp;lt;br&amp;gt;&lt;br /&gt;
The password files maps usernames to user id&#039;s (Linux does not care about your username) &amp;lt;br&amp;gt;&lt;br /&gt;
Normal file access permission check br&amp;gt;&lt;br /&gt;
- compare uid, gid of file with uid, gid of process &amp;lt;br&amp;gt;&lt;br /&gt;
But really: &amp;lt;br&amp;gt;&lt;br /&gt;
- compares it with fsuid, fsgid of process &amp;lt;br&amp;gt;&lt;br /&gt;
- which is normally same as euid, egid of process &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Sshfs&amp;lt;br&amp;gt;&lt;br /&gt;
* Inode values are different in remote vm vs local vm&amp;lt;br&amp;gt;&lt;br /&gt;
* Values increment from 1 in local vm&amp;lt;br&amp;gt;&lt;br /&gt;
* Who&#039;s supplying the inode values?&amp;lt;br&amp;gt;&lt;br /&gt;
** Ext4 filesystem in local vm&amp;lt;br&amp;gt;&lt;br /&gt;
** Fuse.sshfs filesystem in remote vm&amp;lt;br&amp;gt;&lt;br /&gt;
* Filesystem determines the interpretation of inode values&amp;lt;br&amp;gt;&lt;br /&gt;
* Inodes have no meaning outside its filesystem&amp;lt;br&amp;gt;&lt;br /&gt;
* Local to its filesystem =&amp;gt; hardlinks are different too&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;quot;strace ls&amp;quot; in both output the same thing&amp;lt;br&amp;gt;&lt;br /&gt;
* Vfs not built into original unix filesystems&amp;lt;br&amp;gt;&lt;br /&gt;
* Try &amp;quot;strace&amp;quot;ing the sshfs call, see how its interacts with fuse&amp;lt;br&amp;gt;&lt;br /&gt;
* Don&#039;t need to know exact system calls, but you should know when it has to make system calls and why&amp;lt;br&amp;gt;&lt;br /&gt;
** Needs to access files over the network&amp;lt;br&amp;gt;&lt;br /&gt;
* Understand why you can&#039;t do this with regular library calls&amp;lt;br&amp;gt;&lt;br /&gt;
* Removing the root filesystem will trigger a kernel panic&amp;lt;br&amp;gt;&lt;br /&gt;
** Kernel will prevent you from unmounting filesystems that contain other filesystems&amp;lt;br&amp;gt;&lt;br /&gt;
* Kernel modules located in &amp;quot;/lib/modules/&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
* Initial filesystem is loaded into kernel&amp;lt;br&amp;gt;&lt;br /&gt;
** Fake filesystem, throw away after loaded, not persistent&amp;lt;br&amp;gt;&lt;br /&gt;
** Ram disk = filesystem stored in ram&amp;lt;br&amp;gt;&lt;br /&gt;
** Gets the system up to the point where the kernel can load the real filesystem&amp;lt;br&amp;gt;&lt;br /&gt;
** Bootloader has to load both kernel and the initial ram disk into ram&amp;lt;br&amp;gt;&lt;br /&gt;
** Ram disks located in &amp;quot;/boot = initrd.img&amp;lt;...&amp;gt;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
** Kernel version specific&amp;lt;br&amp;gt;&lt;br /&gt;
** Generated as part of installation of kernel&amp;lt;br&amp;gt;&lt;br /&gt;
* Cpio: copies files to and from archives&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* What determines whether you can access a file?&amp;lt;br&amp;gt;&lt;br /&gt;
** The filesystem&amp;lt;br&amp;gt;&lt;br /&gt;
* How to map from user id to username?&amp;lt;br&amp;gt;&lt;br /&gt;
** Recall that&amp;lt;br&amp;gt;&lt;br /&gt;
- Kernel knows nothing about usernames&amp;lt;br&amp;gt;&lt;br /&gt;
- This is a userspace process&amp;lt;br&amp;gt;&lt;br /&gt;
- Looks in local password file&amp;lt;br&amp;gt;&lt;br /&gt;
* What determines whether an operation is allowed?&amp;lt;br&amp;gt;&lt;br /&gt;
** Checks to see who owns the file&amp;lt;br&amp;gt;&lt;br /&gt;
** Compare uid, gid of file with uid, gid of process&amp;lt;br&amp;gt;&lt;br /&gt;
* In remote system, sftp does file access checks&amp;lt;br&amp;gt;&lt;br /&gt;
********************************************************************&lt;br /&gt;
ADDITIONAL NOTES:&lt;br /&gt;
&lt;br /&gt;
Fuse: makes you think who is doing what?&lt;br /&gt;
	How it is connected in the kernel . &lt;br /&gt;
	Fuse.sshfs : is what chose the inode numbers?&lt;br /&gt;
o	Can they be identical to the other inode numbers? &lt;br /&gt;
	Yes but why? &lt;br /&gt;
	What the process of getting the directories? &lt;br /&gt;
The inodes come from the filesystem which you are accessing &lt;br /&gt;
&lt;br /&gt;
Who chose the inode number: the filesystem determine the intereprtation of an inode number, Inode is local to a filesystem.&lt;br /&gt;
How is the kernel obtaining information? : &lt;br /&gt;
Fuse :  has three kinds &lt;br /&gt;
1)	Fuseblk&lt;br /&gt;
2)	Fuse&lt;br /&gt;
3)	Fusectl&lt;br /&gt;
Summary of sshfs: &lt;br /&gt;
Sshfs process that has to make system call to talk to the network to the remote system. &lt;br /&gt;
Similar to a web request , but the difference separate from that we have a different system calls which is the ls process. To do this, the kernel must call a process. &lt;br /&gt;
Does sshfs create 2 processes? Yes , it actually creates multiple of process&lt;br /&gt;
The remote kernel prespective : file accessing files and sending data back to another system. Remote data is not doing anything special. &lt;br /&gt;
*To verify : ps aux | grep ssh &lt;br /&gt;
To learn system call sshfs doing ,running local  strace as much as you can.&lt;br /&gt;
You can mount a file system which would not allow you to mount any further &lt;br /&gt;
When you update the kernel : the initial ram disk will not be update since it is redundant, it will generate it.&lt;br /&gt;
Can we mount a filesystem in a file?&lt;br /&gt;
*&lt;br /&gt;
What is suspicious? A lot of repetitive inodes &lt;br /&gt;
3rd column : amount of hard links. &lt;br /&gt;
Avoid multiple of binaries if you want a small system, you just need the basics. &lt;br /&gt;
After mounting it it loads the linux system.&lt;br /&gt;
Permissions:  the owner can change these permissions, but you can’t take away your own privileges.&lt;br /&gt;
1)	Removing a file : unlinking the file, removing a hardlink which modifies the directory in which a hardlink exists.  Why do I have the permission to remove it? &lt;br /&gt;
2)	Create a file : ouch afile, ls –la afile, &lt;br /&gt;
Premissions: &lt;br /&gt;
1)	Other&lt;br /&gt;
2)	User&lt;br /&gt;
3)	Group &lt;br /&gt;
4)	Files system has EUID( very important because processes can run as a user but have permissions of another user )  AND GID: permissions what you  have and fs is what ur system sees &lt;br /&gt;
Minix system which manages your CPU. &lt;br /&gt;
Busy Box : One binary to pretend it is different programs and we also have a program which pretends to be many. Give it hard link to different names.&lt;br /&gt;
Soma vs anilclass: anil class is special account. The current directory is owned by soma so how did anilclass was able to create a file? Filesystem understands those primission checks? (prof is not sure about this fact and will check it) &lt;br /&gt;
Map a user ID to your user name? it’s a user space problem, kernel doesn’t care about the username. By looking at the password file : grep 1000 /etc/passwd. &lt;br /&gt;
Where are the permissions done in sshfs? (in the steps &lt;br /&gt;
*sftp search process which will determine the permissions. remote file system and the remote kernel (ext4) will check via sftp. All the file access (grabbing the files) &lt;br /&gt;
Verify : ps aux | grep sftp&lt;br /&gt;
Who started this sftp: the sshd did.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
Mount | grep “name” &lt;br /&gt;
Strace ls : directories look the same although they are mounted since ls can not tell , ls is not doing anything differe just opening ur directory and getting data there &lt;br /&gt;
Man sshd : run it and give it aport like 222. Easiest way is using 2 machines on open stack and terminal. It is a good exercise&lt;br /&gt;
Initial Ram disk : to get the real root system to be mounted , similar to memory ll. &lt;br /&gt;
Sudo mount initrd.img-4.10.0-40-generic /mnt : to mount a file in a file system but it didn’t not work and there is an alternative way of doing this &lt;br /&gt;
Anther way : man CPIO : copy files to an form archives . ex : TAR &lt;br /&gt;
CPI  - - help : to figure it out &lt;br /&gt;
Ls –a bin | less&lt;br /&gt;
Cd \ boot : RAM disk &lt;br /&gt;
Du –s –h : in this case (121mb) to see the size of the busy box but the modules takes up half of that space.&lt;br /&gt;
Ls –lai | head &lt;br /&gt;
Chmod a-w : you are unable to write to this directory anymore &lt;br /&gt;
Chmod o+w : granted permission to other….&lt;br /&gt;
Ls –la /bin/fusermount &lt;br /&gt;
Who gives us premissions: just does a normal open and read , the remote kernel enforces these premissions.&lt;br /&gt;
&lt;br /&gt;
=== Lecture 20 ===&lt;br /&gt;
&lt;br /&gt;
$ ls -lai less&lt;br /&gt;
* inode numbers are completely different -&amp;gt; they are determined by the filesystem&lt;br /&gt;
* an inode has no meaning outside its fs; it&#039;s local to the fs&lt;br /&gt;
&lt;br /&gt;
What&#039;s the filesystem?&lt;br /&gt;
* $ df .&lt;br /&gt;
* $ mount | grep vda1&lt;br /&gt;
&lt;br /&gt;
Find fuse fs:&lt;br /&gt;
* $ cat /roc/filesystems | grep fuse&lt;br /&gt;
&lt;br /&gt;
When we run &amp;quot;ls&amp;quot; on an sshfs-mounted filesystem&lt;br /&gt;
* ls makes system calls (open, getdents) to the local linux kernel&lt;br /&gt;
* the local kernel sees filesystem is FUSE, calls FUSE routines for open, getdents... (via vfs abstraction)&lt;br /&gt;
* FUSE calls the sshfs process that mounted the filesystem&lt;br /&gt;
:* $ ps aux | grep sshfs&lt;br /&gt;
* sshfs is itself a process that has to make system calls to talk over the network to the remote system&lt;br /&gt;
* sshfs process sends request to the remote system&lt;br /&gt;
::* via socket system calls&lt;br /&gt;
* remote sshd process receives request (via system calls)&lt;br /&gt;
* remote sshd process accesses local filesystem&lt;br /&gt;
::* makes open, getdents system calls&lt;br /&gt;
::* remote kernel checks vfs, calls ext4 routines to access data&lt;br /&gt;
* remote sshd process responds to request (via system calls)&lt;br /&gt;
* local sshfs process receives response (via system calls)&lt;br /&gt;
* local sshfs process responds to FUSE request&lt;br /&gt;
* FUSE passes data back to vfs layer, then back to requesting process&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Initial ramdisks - Tue 28 Nov 2017 13:44:34 EST&lt;br /&gt;
:* bootloaded loads both the kernel and initial ramdisk into RAM on boot&lt;br /&gt;
:* /boot -&amp;gt; initrd. = ramdisk&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* $ du -s -h asdf/asdflkj/gkgk&lt;br /&gt;
* $ du -s -h .&lt;br /&gt;
&lt;br /&gt;
Display a pid&#039;s euid&lt;br /&gt;
* $ ps -eo pid, euid | grep YOUR_PID_HERE&lt;br /&gt;
* $ ps -eo pid, euid, ruid, suid | grep YOUR_PID_HERE&lt;br /&gt;
&lt;br /&gt;
List mounts:&lt;br /&gt;
* $ mount -l&lt;br /&gt;
* $ df -aTh&lt;br /&gt;
&lt;br /&gt;
[https://help.ubuntu.com/community/SSHFS SSHFS]&lt;br /&gt;
[https://www.cs.nmsu.edu/~pfeiffer/fuse-tutorial/ &amp;quot;Writing a FUSE FS: A tutorial&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Aleksp</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_22&amp;diff=21356</id>
		<title>Operating Systems 2017F Lecture 22</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_22&amp;diff=21356"/>
		<updated>2017-12-07T16:58:24Z</updated>

		<summary type="html">&lt;p&gt;Aleksp: /* In Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
[http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec22-05Dec2017.mp4 Lecture 22 Video]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
===In Class===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 22&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
What&#039;s left?&lt;br /&gt;
&lt;br /&gt;
* scheduling&lt;br /&gt;
* device drivers&lt;br /&gt;
* virtual memory&lt;br /&gt;
  - page replacement algorithms&lt;br /&gt;
    - predict the future (optimal)&lt;br /&gt;
    - least recently used&lt;br /&gt;
    - one-handed, two-handed clocks&lt;br /&gt;
* power management&lt;br /&gt;
* security&lt;br /&gt;
  - hardening processes so coding errors don&#039;t lead to vulnerabilities&lt;br /&gt;
    (machine code injection, e.g. buffer overflow attacks)&lt;br /&gt;
&lt;br /&gt;
* virtualization&lt;br /&gt;
  - hardware-level  (run multiple kernels)  &amp;lt;-- vmware, openstack&lt;br /&gt;
  - OS-level        (run multiple userspaces) &amp;lt;-- containers, web hosting&lt;br /&gt;
  - application level (run programs on simulated machines)&lt;br /&gt;
     - JVM&lt;br /&gt;
     - JavaScript runtime in browsers/node&lt;br /&gt;
 &lt;br /&gt;
* distributed operating systems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ADDITIONAL NOTES :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Comp 3000&lt;br /&gt;
Premissions on this directory, readable writable and executable&lt;br /&gt;
Execute permission on a Regular file : you can execute &lt;br /&gt;
Execute permission on a directory : follow the links on the directory&lt;br /&gt;
Can’t make any changes to the directory if you can’t write&lt;br /&gt;
There are exceptions :  &lt;br /&gt;
Less/etc/passwd: doesn’t actually store the password&lt;br /&gt;
 if you want to change this file, you must have a way to allow limited editing to this. &lt;br /&gt;
	You can have a process running as root and send it signals and tell it to update the entry in the password file. &lt;br /&gt;
o	Starting up a process which has more privileges which I can do , ex: EUID &lt;br /&gt;
Ls –la /sbin | grep rws : execve EUID will be set to whatever it is from the file . equal to the uid&lt;br /&gt;
Ls –la /sbin | grep r-s: s is a sticky bit, if you need extra premissions &lt;br /&gt;
You want your stcky bit to be a regular user &lt;br /&gt;
Euid = uid yes&lt;br /&gt;
Cd /tmp : directory in which everyone can write &lt;br /&gt;
This allows binaries run as users&lt;br /&gt;
Set uid and get guid : &lt;br /&gt;
Myid has euid now &lt;br /&gt;
Change the ownership &lt;br /&gt;
-	&amp;gt; chown root : root myid &lt;br /&gt;
-	&amp;gt;chown root : root mytouch &lt;br /&gt;
Ls –la : 3rd column identifies the ownership of each file on the file system&lt;br /&gt;
You can overwrite any file on the fille system using mytouch binary &lt;br /&gt;
Question : why can you remove file owned by root? &lt;br /&gt;
-	&amp;gt; to change the context of the directory , the permissions of a file don’t matter but the permissions and privileges  of the directory only matter&lt;br /&gt;
o	Someone putting a directory in ur directory is hard to remove&lt;br /&gt;
-	Ssh to a remote serve : &lt;br /&gt;
-	2 public keys involved: identity key, private key pair: one in the known host file (connecting to the machine). &lt;br /&gt;
-	If you rm _known host and do ssh , a question will ask you to add the key to ur host file &lt;br /&gt;
-	What happens if a person tries to personate your machine (same IP address)? &lt;br /&gt;
o	It will identity it is a fake person from the host&lt;br /&gt;
First line is a Hashed versionof an IP address : cat .ssh/known_host &lt;br /&gt;
Ssh demon : running in the background and must have a public key to identify its self. process that runs in the background that doesn’t run in the background(connects 1 file system to another)&lt;br /&gt;
-	&amp;gt; connects sockets and listens to connect. Doesn’t interact with user&lt;br /&gt;
Thursday: written version of the solutions for the midterm and we will talk about assignment 4 &lt;br /&gt;
3000 class content &lt;br /&gt;
We didn’t discuss scheduling much : &lt;br /&gt;
Virtual memory: similar to scheduling since, If you don’t have enough memory , you delete the page that you may want to need at last . Choosing which pages you replace : one-handed and two-handed clocks&lt;br /&gt;
Power management &lt;br /&gt;
Security &lt;br /&gt;
Virtualization : not one thing , vm ware, system which run multiple of kernels.&lt;br /&gt;
SSH question student asked, how can they know that they have the private key belongs to the pubkey it belongs to: sends a public key or a hash of th Pubkey , then an exchange : yes I have a secret key which can be inverted by the pubkey. Private key must be corresponding. encrypts with thr private key and sends it back&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Lecture 22&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Synopsis&#039;&#039;&#039;: UID, GUID, EUID, setuid, setguid&lt;br /&gt;
&lt;br /&gt;
What is and isn&#039;t permitted on a Linux system?&lt;br /&gt;
* a file we create has a user ID and group ID&lt;br /&gt;
** i.e. $ touch&lt;br /&gt;
** $ which touch&lt;br /&gt;
** $ ls -la /bin/touch&lt;br /&gt;
&lt;br /&gt;
::* touch is owned by root, but has global execute permissions&lt;br /&gt;
&lt;br /&gt;
* fork and execve don&#039;t change the user ID of a process&lt;br /&gt;
* when we create a file, system checks user ID/group ID under which a process is running&lt;br /&gt;
&lt;br /&gt;
::* if we want to create a file somewhere&lt;br /&gt;
::* check permissions on the dir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== N.B. ==== &lt;br /&gt;
* on a dir, execute permissions means you can follow the links on the dir; write permissions mean we can create a file&lt;br /&gt;
&lt;br /&gt;
* to change contents of a directory (i.e. remove a file), the permissions on the file don&#039;t matter -&amp;gt; the permissions on the directory do!&lt;br /&gt;
&lt;br /&gt;
:* Read permissions let us read the dir, obtain all the file names contained within&lt;br /&gt;
:* Execute permission lets us pass through the dir when we need to search it to look for a specific filename&lt;br /&gt;
:* To create a new file in a directory, we need to have write and execute permissions&lt;br /&gt;
&lt;br /&gt;
:::* exceptions to this:&lt;br /&gt;
::::* $ /etc/passwd&lt;br /&gt;
::::* $ ls -la /etc/passwd&lt;br /&gt;
&lt;br /&gt;
::::* we have a process running as root, to which we can send a message/request using IPC and request a change&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* how to start up a process that has more privilages than we do? -&amp;gt; effective UID&lt;br /&gt;
** EUID can be set by special permissions -&amp;gt; sticky bits&lt;br /&gt;
*** after an execve the resulting process will have it&#039;s group and user ID set accordingly&lt;br /&gt;
*** setting the sticky bit, causes the binary to run as that user&lt;br /&gt;
**** any files created will have the user&#039;s group&lt;/div&gt;</summary>
		<author><name>Aleksp</name></author>
	</entry>
</feed>