UNIX (xv6) 操作系统

UNIX (xv6) 操作系统

2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

UNIX 传奇

center

Dennis M. Ritchie, Ken Thompson, and PDP-11
2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

The UNIX Time-Sharing System

机缘巧合:正确的时间、地点、人物 (dmr 和 ken)

The genius of Ritchie and Thompson is in their selection of a subset of the most powerful functions of MULTICS (especially processes, directory hierarchies, stream-oriented IO, file-like devices, and the shell) together with their own invention of the pipe.

  • 在复杂的迷雾中看到本质 (paper)
  • The most important characteristics of the system are its simplicity, elegance, and ease of use.
    • “Three weeks away from an OS”: 花 3 周写了一个编辑器、一个汇编器、一个 shell (彻底 “能用” 了)
2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

风靡世界

AT&T 不能销售计算机软件

center

2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

蠕虫病毒 (1988)

Robert Morris (时年 23 岁,就读于 Cornell)

  • 从漏洞注入代码开始
    • 尝试通过字典攻击和简单的暴力破解来猜测网络上的用户密码
    • 是的,那个时候整个世界的代码都是 “操作系统实验”
      • (Morris 低估了病毒造成的后果)
      • 第一个在互联网广为传播的病毒
  • 《计算机欺诈及滥用法案》定罪的第一宗案件
    • 三年缓刑,罚款一万美金,400 小时义工
    • (后来他成为了 MIT 的教授)
2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

The Morris Worm

sendmail

  • Debug mode 直接给开了后门……

fingerd (information about system users; finger = “👈”)

  • gets(buf) 引发的血案

传播到全世界

  • Password security: A case history (Robert Morris, Ken Thompson, Communications of the ACM, 1979)
    • (这是 Robert Morris Sr.)
    • 然后开始自我复制:从 /etc/hosts.equiv, /.rhosts, ... 寻找下一个目标 (只是复制,没有破坏)
2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

xv6: A Modern UNIXv6

三位作者

一个大胆的改革想法

  • 砍掉本课程的全部内核部分
  • 剩下的部分交给 xv6
2024 南京大学《操作系统:设计与实现》
UNIX (xv6) 操作系统

Debugging xv6

基础设施

  • 准备好脚本

调试

  • xv6 启动
  • ecall to Trampoline (系统调用)
    • 保存 mepc = PC
    • 跳转 PC = (mtvec & ~0xf)
    • 更新 mcause.Ecall = 1
2024 南京大学《操作系统:设计与实现》