Time to retire Linux (and C) in IoT Lin Zhong http://www.recg.org - - PowerPoint PPT Presentation

time to retire linux and c in iot
SMART_READER_LITE
LIVE PREVIEW

Time to retire Linux (and C) in IoT Lin Zhong http://www.recg.org - - PowerPoint PPT Presentation

Time to retire Linux (and C) in IoT Lin Zhong http://www.recg.org By analyzing the problems of Linux, create a software systems research agenda for secure, efficient IoT devices. 2 Our mission better computers http://www.recg.org BIG World


slide-1
SLIDE 1

Time to retire Linux (and C) in IoT

Lin Zhong http://www.recg.org

slide-2
SLIDE 2

By analyzing the problems of Linux, create a software systems research agenda for secure, efficient IoT devices.

2

slide-3
SLIDE 3

Our mission better computers

http://www.recg.org

slide-4
SLIDE 4

4

World first massive MIMO system prototype

BIG

slide-5
SLIDE 5

Small

5

Mobile & embedded software systems & hardware

slide-6
SLIDE 6

Linux is taking over the world

6

slide-7
SLIDE 7

Linux IoT devices in our home

7

slide-8
SLIDE 8

Large Hadron Collider @CERN

8

slide-9
SLIDE 9

DeLaval automatic cow milking machine

9

slide-10
SLIDE 10

Cars

10

slide-11
SLIDE 11

April 2014

slide-12
SLIDE 12
slide-13
SLIDE 13

Why IoT devices embrace Linux

  • Moore’s Law made silicon cheaper
  • 8-bit => 16-bit => 32-bit => 32-bit with MMU
  • Linux is free and ready available
  • well seasoned network stack

13

slide-14
SLIDE 14

The security crisis

14

slide-15
SLIDE 15

15

slide-16
SLIDE 16

16

slide-17
SLIDE 17

Four botnets generated 10 DDoS attacks exceeding 300 Gbps between July 2014 and December

  • 2016. Seven of these occurred in 2016
  • Oct. 16

July 14 321 July 14 312

  • Dec. 15

309

  • Apr. 16

337 June 16 363

  • Sept. 16

623

  • Sept. 16

555 517

  • Oct. 16

300

  • Oct. 16

306 Mirai BillGates Kaiten XOR Spike

Security Spotlight: Internet of Things and the Rise of 300 Gbps DDoS Attacks

Source: akamai

slide-18
SLIDE 18

Security Spotlight: Internet of Things and the Rise of 300 Gbps DDoS Attacks

Source: akamai

A rapid increase in scans of port 23 and 2323 began on May 13, 2016 as the Mirai botnet attempted to log into unsecure IoT devices.

Feb. Mar. Apr. May June July Aug. Sep. Oct. Nov. 1M 1.5M 2M 2.5M 500K Source IP Count Kaiten botnet discovered First major Mirai attack DYN DNS attack

slide-19
SLIDE 19

The crisis is rooted in Linux/C

19

slide-20
SLIDE 20

C is not safe

  • No memory (type)

safety

20

  • No language support

for concurrency

slide-21
SLIDE 21

Most kernel vulnerabilities rooted in C

Chen et al APSys 2011

Vulnerability

  • Mem. corruption

Policy violation DoS

  • Info. disclosure

Misc. Missing pointer check 6 1 2 Missing permission check 15 3 1 Buffer overflow 13 1 1 2 Integer overflow 12 5 3 Uninitialized data 1 28 Null dereference 20 Divide by zero 4 Infinite loop 3 Data race / deadlock 1 7 Memory mismanagement 10 Miscellaneous 5 2 1 Total 32 16 60 37 2

slide-22
SLIDE 22

Linux depends on human developers for correctness

22

“Give enough eye balls, all bugs are shallow” — Linus’ Law

slide-23
SLIDE 23

Linux depends on human developers for correctness

Linus Towalds, 2007

Keep incompetent programmers out by choosing C

slide-24
SLIDE 24

No guarantee

Introduced by Robin Seggelmann in 2011, code reviewed by Stephen Henson, into OpenSSL source code, 12/31/2011 Bug reported 04/01/2014

slide-25
SLIDE 25

It’s worse for IoT devices

  • Not many eye balls
  • Not many competent developers
  • Low profit margin
  • Short-time to market

25

slide-26
SLIDE 26

IoT system kernel is driver-rich

System-on-a-chip for IoT devices teeming with non-CPU devices

Drivers are the most buggy part of kernel

slide-27
SLIDE 27

There are a lot of IoT devices. There are a lot of IoT vendors.

slide-28
SLIDE 28

Sturgeon’s Law: 90% of everything is crap

slide-29
SLIDE 29

Sturgeon’s Law: 90% of IoT vendors are crap

  • Device shipped with debug access enabled
  • Hard-coded passwords
  • Unused features left in
  • Difficult to manage
  • Impossible to update

Christopher Biggs, “The Internet of Scary Things - tips to deploy and manage IoT safely”, 2017

slide-30
SLIDE 30

Sturgeon’s Law: 90% of IoT devices are crap

Top ten attack origins on monitored IoT honeypot in 2016, by count of unique attackers (Source: Symantec)

slide-31
SLIDE 31

31

“When identical devices are manufactured and sold in huge quantities, the possibility for mass takeover of those devices is real.” —Jonathan Corbet, Internet of Scary Things, LWN, 2017

slide-32
SLIDE 32

All top IoT malware identified by Symantec affect Linux systems

  • Linux.Darlloz (aka Zollard)
  • Linux.Aidra / Linux.Lightaidra
  • Linux.Xorddos (aka

XOR.DDos)

  • Linux.Gafgyt (aka GayFgt,

Bashlite)

  • Linux.Ballpit (aka

LizardStresser)

  • Linux.Moose
  • Linux.Dofloo (aka AES.DDoS,
  • Mr. Black)
  • Linux.Pinscan /

Linux.Pinscan.B (aka PNScan)

  • Linux.Kaiten / Linux.Kaiten.B

(aka Tsunami)

  • Linux.Routrem (aka

Remainten, KTN-Remastered, KTN-RM)

  • Linux.Wifatch (aka Ifwatch)
  • Linux.LuaBot

Source: Symantec 2016 https://www.symantec.com/connect/blogs/iot-devices-being-increasingly-used-ddos-attacks

slide-33
SLIDE 33

https://www.theregister.co.uk/2017/01/19/iot_will_get_worse_before_it_gets_better_dev_tells_linux_conference/

slide-34
SLIDE 34

34

IoT security is about securing the bottom 10%

slide-35
SLIDE 35

Linux/C invites hardware- based isolation

  • Privilege levels
  • User, kernel, hypervisor, monitor….
  • MMU
  • Intel SGX, ARM TrustZone

35

slide-36
SLIDE 36

Microsoft Azure Sphere

requires more complicated hardware

Figure 1. Architecture of the MT7687 Wi-Fi-enabled Microcontroller. With MediaTek’s assistance we modified and extended the MT7687. We made three changes to the MediaTek’s

Microcontroller Die

WiFi Subsystem CPU GPIO, etc. SRAM GPU MMU GPU MMU GPU MMU Flash Controller Flash Memory SHA, MD & AES Cryptographic Engines Hardware RNG Boot ROM PMU GPU MMU Interconnect Fabric

With MediaTek’s assistance we modified and extended the MT7687. We made three changes to the Figure 2. Architecture of the Experimental Sopris Highly Secure WiFi-enabled Microcontroller. MediaTek’s

The Seven Properties of Highly Secure Devices Galen Hunt, George Letey, and Edmund B. Nightingale Microsoft Research NExT Operating Systems Technologies Group

slide-37
SLIDE 37

Shall we trust hardware for isolation?

Unprivileged process accessing privileged data Failure of privilege levels Process accessing address out of bound Failure of MMU isolation

37

slide-38
SLIDE 38

Monsters in our home aka the toaster apocalypse

38

slide-39
SLIDE 39

Monsters in our home aka the toaster apocalypse

39

slide-40
SLIDE 40

IoT OS Wishlist

  • C => Safe language
  • No reliance on hardware isolation

40

slide-41
SLIDE 41

Linux has an efficiency problem

41

slide-42
SLIDE 42

Runtime enforcement of correctness is expensive

Design time Implmtn. time Compile time Install time Load time Run time Post mortem

Time of enforcement

Inspired by Hunt & Larus (2004)

Linux/C

{

42

slide-43
SLIDE 43

Expensive system calls

  • Mode switch overhead: Stack access, exception handling
  • Locality reduction: cache, TLB pollution

2000 4000 6000 8000 10000 12000 14000 16000

0.3 0.5 0.7 0.9 1.1 1.3 1.5

Syscall impact on user-mode IPC Time (in cycles) User-mode IPC (higher is faster) Syscall exception Lost performance (cycles)

2000 4000 6000 8000 10000 12000 14000 16000

0.3 0.5 0.7 0.9 1.1 1.3 1.5

Syscall impact on user-mode IPC Time (in cycles) User-mode IPC (higher is faster) Syscall exception Lost performance (cycles)

Soares & Stumm, OSDI 2010

43

slide-44
SLIDE 44

IoT services are I/O and network-oriented

  • A piece of sensor data has to cross

the user-kernel boundary twice!!!

44

slide-45
SLIDE 45

IoT OS Wishlist

  • C => Safe language
  • No reliance on hardware isolation
  • Runtime enforcement => Static enforcement

45

slide-46
SLIDE 46

Linux has a maintainability problem

46

slide-47
SLIDE 47

Too big too complex for innovation

Lines of code (Million) 0.1 1 10 100 1991 1994 1997 2000 2003 2006 2009 2012 2015 2018

Linux Kernel

47

slide-48
SLIDE 48

Highly modularized but entangled

task mgmt

nano-core

kern el cons

  • le

input event mux key boar d indir ecti

  • n

laye r s c h e d u l e r CFQ policy FCFS policy RR policy mouse indirection layer VGA indirection layer graphics mux filesystem PIC IRQ PIT clock IRQ event dispatcher syscall dispatcher sysc all indir ecti

  • n

laye r heap allocator frame allocator stack allocator

userspace processes

PIC IRQ s c h e d u l e r filesystem PIC IRQ PIC IRQ filesyst em fil e s y st e m

(a) Monolithic Kernel (b) Microkernel OS (c) Theseus Kernel

module submodule entanglement via state spill

s c h e d u l e r filesyst em s c h e d ul er

Modules contain submodules Modules hold states for each other Fate sharing Live update almost impossible

48

slide-49
SLIDE 49
  • When one software entity’s state undergoes a lasting change

as a result of handling an interaction with another entity.

  • Migration, fault isolation,

fault tolerance, live update, hot-swapping, maintainability…..

Kevin Boos, et al. A Characterization of State Spill in Modern Operating Systems. EuroSys, 2017.

State spill is ubiquitous and deep

49

slide-50
SLIDE 50

State spill explained

50

Vice President Body man

slide-51
SLIDE 51

Solution in Data center

Leverage redundancy Add layers of indirection

51

slide-52
SLIDE 52

Redundancy is a luxury out

  • f Data Center

52

slide-53
SLIDE 53

Either bring the service down

53

slide-54
SLIDE 54

Reboot a powerplug?

54

slide-55
SLIDE 55

Or never updated

55

slide-56
SLIDE 56
slide-57
SLIDE 57

Getting older and disappearing

https://blog.bitergia.com/2013/02/01/demographics-of-linux-kernel-developers-how-old-are-they/

slide-58
SLIDE 58

Voyager 2: 40 years after launch, 20 Billion km away

58

slide-59
SLIDE 59

59

slide-60
SLIDE 60

IoT OS Wishlist

  • C => Safe language
  • No reliance on hardware isolation
  • Runtime enforcement => Early enforcement
  • Modularization => Spill free modularization

60

slide-61
SLIDE 61

“Let’s retire Linux/C”

61

slide-62
SLIDE 62

“Why? Linux/C must be good since it has taken

  • ver the world”

62

slide-63
SLIDE 63

QWERTY phenomenon

63

slide-64
SLIDE 64

Ken Thompson and Dennis Ritchie DEC PDP-11, 16 bit, 1970-ish

64

slide-65
SLIDE 65

USA $ 0.0001 0.001 0.01 0.1 1 10 1965 1975 1985 1995 2005

USA Federal minimum wage in 2003 dollar Average transistor price for Intel processors in contemporary dollar

Designed at a time when computer was simpler and more expensive by orders of magnitude

65

PDP11 <

slide-66
SLIDE 66

USA $ 0.0001 0.001 0.01 0.1 1 10 1965 1975 1985 1995 2005

USA Federal minimum wage in 2003 dollar Average transistor price for Intel processors in contemporary dollar

Humans were relatively cheap; Let developers manage memory and concurrency

66

slide-67
SLIDE 67

USA $ 0.0001 0.001 0.01 0.1 1 10 1965 1975 1985 1995 2005

USA Federal minimum wage in 2003 dollar Average transistor price for Intel processors in contemporary dollar

Computing is relative cheap; Let machine manage memory and concurrency

67

slide-68
SLIDE 68

“Unix and C are the ultimate computer virus”

Richard Gabriel in The Rise of ``Worse is Better’'

68

slide-69
SLIDE 69

Getting older and disappearing

https://blog.bitergia.com/2013/02/01/demographics-of-linux-kernel-developers-how-old-are-they/

Maybe this is good news!

slide-70
SLIDE 70

Science makes progress funeral by funeral

“A new scientific truth does not triumph by convincing its

  • pponents and making them see the light, but rather because

its opponents eventually die, and a new generation grows up that is familiar with it.” ——— Max Planck

70

slide-71
SLIDE 71

Then what?

71

slide-72
SLIDE 72

IoT OS Wishlist

  • C => Safe language
  • No reliance on hardware isolation
  • Runtime enforcement => Early enforcement
  • Modularization => Spill free modularization

72

slide-73
SLIDE 73

Theseus: a runtime composable OS

73

slide-74
SLIDE 74

Ship of Theseus

The ship wherein Theseus and the youth of Athens returned from Crete had thirty oars, and was preserved by the Athenians down even to the time of Demetrius Phalereus, for they took away the old planks as they decayed, putting in new and stronger timber in their places, in so much that this ship became a standing example among the philosophers, for the logical question

  • f things that grow;
  • ne side holding that the ship

remained the same, and the other contending that it was not the same.
 — Plutarch (Theseus)

74

slide-75
SLIDE 75
  • 1. Rise up to the language
  • pportunity
  • Safe languages have been tried in the past
  • Modula-2, Oberon, Erlang, C#, Java, Go, ….

75

None took off due to underlying runtime or garbage collection requirement

slide-76
SLIDE 76

Rust

born 2010 at Mozilla Research to develop a new web engine

  • NO RUNTIME, NO GARBAGE COLLECTION!!!
  • Memory (and type) safe
  • Concurrency safe
  • Performance close to C
  • Strong type systems for static enforcement of

correctness

76

slide-77
SLIDE 77
  • 2. No reliance on hardware

isolation

  • Hardware isolation is expensive and difficult to

verify, incurs runtime overhead

slide-78
SLIDE 78

End-to-end argument

“Functions placed at low levels of a system may be redundant or of little value when compared with the cost of providing them at that low level.”

Saltzer, Reed & Clark 1984

78

slide-79
SLIDE 79
  • 2. No reliance on hardware

isolation

  • Hardware should focus on performance and

efficiency

  • Software (the end) enforces isolation

Tock (SOSP’17) shows software isolation is achievable on low-cost micro controller WITHOUT MMU

slide-80
SLIDE 80

80

Design time Implmtn. time Compile time Install time Load time Run time Post mortem

Time of enforcement

Linux/C

{

Strong, novel type systems

  • 3. Earlier enforcement of correctness

Rust opens the door

slide-81
SLIDE 81
  • 3. Earlier enforcement of correctness

Rust opens the door

  • Trust the compiler/type system
  • Run all software in the same privilege mode
  • Disappearing OS/kernel

81

slide-82
SLIDE 82

Design time Implmtn. time Compile time Install time Load time Run time Post mortem

Time of enforcement

Inspired by Hunt & Larus (2004)

Linux/C

{

Theseus/Rust

{

If Linux/C is airport security check Theseus/Rust is TSA Pre

slide-83
SLIDE 83
  • 4. Spill free modularization

83

task mgmt

nano-core

kern el cons

  • le

input event mux key boar d indir ecti

  • n

laye r s c h e d u l e r CFQ policy FCFS policy RR policy mouse indirection layer VGA indirection layer graphics mux filesystem PIC IRQ PIT clock IRQ event dispatcher syscall dispatcher sysc all indir ecti

  • n

laye r heap allocator frame allocator stack allocator

userspace processes

PIC IRQ s c h e d u l e r filesystem PIC IRQ PIC IRQ filesyst em fil e s y st e m

(a) Monolithic Kernel (b) Microkernel OS (c) Theseus Kernel

module submodule entanglement via state spill

s c h e d u l e r filesyst em s c h e d ul er

slide-84
SLIDE 84

Building Modules in Isolation

  • Each module is a separate Rust crate
  • Compiled into individual binaries, isolated into private

“namespaces”

84

Compiler

Compiler/Linker

Theseus
 Easy to extricate a single crate due to clear boundaries Standard OS No true distinction between modules, or blurry lines

slide-85
SLIDE 85
  • 4. Spill free modularization
task mgmt

nano-core

kern el cons
  • le
input event mux key boar d indir ecti
  • n
laye r s c h e d u l e r CFQ policy FCFS policy RR policy mouse indirection layer VGA indirection layer graphics mux filesystem PIC IRQ PIT clock IRQ event dispatcher syscall dispatcher sysc all indir ecti
  • n
laye r heap allocator frame allocator stack allocator

userspace processes

PIC IRQ s c h e d u l e r filesystem PIC IRQ PIC IRQ filesyst em fil e s y st e m

(a) Monolithic Kernel (b) Microkernel OS (c) Theseus Kernel

module submodule entanglement via state spill

s c h e d u l e r filesyst em s c h e d ul er

Implementing the OS like a distributed system

  • f tiny modules

Theseus is “a bag of modules”

slide-86
SLIDE 86

Open questions

  • Performance optimization
  • Spill freedom can incur 3X slowdown
  • Do more at Compile time?
  • Can Type System do more? (State spill as

session types)

  • Design for formal verification

86

slide-87
SLIDE 87

IoT OS Wishlist

  • C => Safe language
  • No reliance on hardware isolation
  • Runtime enforcement => Early enforcement
  • Modularization => Spill free modularization

87

slide-88
SLIDE 88

89

slide-89
SLIDE 89

(Competent) C programmers are slowly getting rarer

90

20% 6% 14%

slide-90
SLIDE 90

(Competent) C programmers are slowly getting rarer

91

5% 3%