Native Client Native Client Evgeny Eltsin
Overview Why Native Client? What is it? How it works? Ecosystem Developer stuff
Why Native Client? Close the gap between desktop and web apps Performance Choice of programming language Leverage legacy code
Why Native Client? Close the gap between desktop and web apps Safety Portability
Web Apps Interpreted languages (JavaScript) Safe but often slow
How to Improve? Just-In-Time compiler Faster (fast enough?) and often complex (more vulnerable ?)
Web Apps Native code "as is" (ActiveX) Fast but not safe
How to Improve? Make native code "manageable"? OS gives few options
What is Native Client? NaCl — system for safe execution of untrusted native code In a web browser … Open-source http://code.google.com/p/nativeclient
What is it Good for? Port desktop apps to web Zero install Performance close to native
What is it Good for? Enhance web apps with C/C++/... libraries (libcrypt, CGAL, ...) New high-performance code (threads, hand-coded asm, ...)
What is it Good for? Sandbox existing plugins Stop asking users to trust your code
Lunch isn't Free Must recompile from source and do some porting Part of system interfaces are unavailable Still work in progress
What is Safe? No side effects except via explicit secure interfaces
Runtime Sandbox No side effects ... No read, write or execute outside of the sandbox ... except via explicit secure interfaces "system calls"
How it Works? Runtime sandbox is created via an agreement between Code generator (untrusted) Validator and loader (trusted) Trusted part is simple
What Code Validation is? First, disassemble all executable code No overlapping instructions Run-time code generation needs special support
Control Flow Integrity Do we jump to code we know? Direct jumps are easy to validate but indirect ?
Instruction Bundles Every bundle-aligned code address is a potential jump target No instructions cross bundle boundaries Code generator pads with NOPs Bundle is 32-bytes (chosen from experiment)
Instruction Bundles Indirect jump always go to a bundle-aligned address Code generator makes code to enforce Validator checks enforcement
i386 Example call 0x1280(%eax) lea 0x1280(%eax), %eax and 0xffffffe0, %eax call *%eax
Checking Read, Write and Jump i386 Example Validator checks instructions use correct segment registers Loader sets segment registers correctly Loader protects memory accordingly
System Calls Trampoline to outer stuff Valid jump target inside the sandbox Does "context switch" and jump out of the sandbox Generated by trusted loader
Ecosystem Availability i386, x86_64, ARM Linux, Windows, MacOS chrome —enable-nacl Firefox plugin (fewer features than in Chrome, unfortunately)
Portability PNaCl - work in progress Portable representation (LLVM bitcode) Final translation on the client or translation/cache server
Deployment HTML <EMBED> Binary picked by client architecture Scripting interface
What works? Gallery at http://code.google.com/p/nativeclient And much more stuff Quake Video decoder Python
Developer Stuff ILP32 data model for all architectures Linux-like programming environment ELF binaries Netscape Plugin API/Pepper Plugin API
Native Client SDK http://code.google.com/p/nativeclient-sdk Ported Gnu toolchain gcc 4.4.3 (4.5 coming) newlib (glibc coming)
Native Client Ports http://code.google.com/p/naclports zlib cairo mesa theora expat
Developers Welcome! Lot of fun projects GTK SDL and your choice of cool stuff!
Thank You! Questions?

Native client (Евгений Эльцин)

  • 1.
    Native Client NativeClient Evgeny Eltsin
  • 2.
    Overview Why NativeClient? What is it? How it works? Ecosystem Developer stuff
  • 3.
    Why Native Client?Close the gap between desktop and web apps Performance Choice of programming language Leverage legacy code
  • 4.
    Why Native Client?Close the gap between desktop and web apps Safety Portability
  • 5.
    Web Apps Interpretedlanguages (JavaScript) Safe but often slow
  • 6.
    How to Improve?Just-In-Time compiler Faster (fast enough?) and often complex (more vulnerable ?)
  • 7.
    Web Apps Nativecode &quot;as is&quot; (ActiveX) Fast but not safe
  • 8.
    How to Improve?Make native code &quot;manageable&quot;? OS gives few options
  • 9.
    What is NativeClient? NaCl — system for safe execution of untrusted native code In a web browser … Open-source http://code.google.com/p/nativeclient
  • 10.
    What is itGood for? Port desktop apps to web Zero install Performance close to native
  • 11.
    What is itGood for? Enhance web apps with C/C++/... libraries (libcrypt, CGAL, ...) New high-performance code (threads, hand-coded asm, ...)
  • 12.
    What is itGood for? Sandbox existing plugins Stop asking users to trust your code
  • 13.
    Lunch isn't FreeMust recompile from source and do some porting Part of system interfaces are unavailable Still work in progress
  • 14.
    What is Safe?No side effects except via explicit secure interfaces
  • 15.
    Runtime Sandbox Noside effects ... No read, write or execute outside of the sandbox ... except via explicit secure interfaces &quot;system calls&quot;
  • 16.
    How it Works?Runtime sandbox is created via an agreement between Code generator (untrusted) Validator and loader (trusted) Trusted part is simple
  • 17.
    What Code Validationis? First, disassemble all executable code No overlapping instructions Run-time code generation needs special support
  • 18.
    Control Flow IntegrityDo we jump to code we know? Direct jumps are easy to validate but indirect ?
  • 19.
    Instruction Bundles Everybundle-aligned code address is a potential jump target No instructions cross bundle boundaries Code generator pads with NOPs Bundle is 32-bytes (chosen from experiment)
  • 20.
    Instruction Bundles Indirectjump always go to a bundle-aligned address Code generator makes code to enforce Validator checks enforcement
  • 21.
    i386 Example call0x1280(%eax) lea 0x1280(%eax), %eax and 0xffffffe0, %eax call *%eax
  • 22.
    Checking Read, Writeand Jump i386 Example Validator checks instructions use correct segment registers Loader sets segment registers correctly Loader protects memory accordingly
  • 23.
    System Calls Trampolineto outer stuff Valid jump target inside the sandbox Does &quot;context switch&quot; and jump out of the sandbox Generated by trusted loader
  • 24.
    Ecosystem Availability i386,x86_64, ARM Linux, Windows, MacOS chrome —enable-nacl Firefox plugin (fewer features than in Chrome, unfortunately)
  • 25.
    Portability PNaCl -work in progress Portable representation (LLVM bitcode) Final translation on the client or translation/cache server
  • 26.
    Deployment HTML <EMBED>Binary picked by client architecture Scripting interface
  • 27.
    What works? Galleryat http://code.google.com/p/nativeclient And much more stuff Quake Video decoder Python
  • 28.
    Developer Stuff ILP32data model for all architectures Linux-like programming environment ELF binaries Netscape Plugin API/Pepper Plugin API
  • 29.
    Native Client SDKhttp://code.google.com/p/nativeclient-sdk Ported Gnu toolchain gcc 4.4.3 (4.5 coming) newlib (glibc coming)
  • 30.
    Native Client Portshttp://code.google.com/p/naclports zlib cairo mesa theora expat
  • 31.
    Developers Welcome! Lotof fun projects GTK SDL and your choice of cool stuff!
  • 32.