《賈曉宇-Building Linux Distribution from Scratch with Rust.pdf》由會員分享,可在線閱讀,更多相關《賈曉宇-Building Linux Distribution from Scratch with Rust.pdf(19頁珍藏版)》請在三個皮匠報告上搜索。
1、第三屆中國Rust開發者大會Building Linux Distribution from Scratch with RustSpeaker:Jia XiaoyuCONTENTSWhy choose rust?Using Rust and LFS build linux distroO2What rkos brings us?Why do we choose Rust?Why do we choose Rust?PhoTto/image/chartWhy do we want to use Rust to build most of the things in the Operating s
2、ystem?1.If you have a very large(millions of lines of code)codebase,written in a memory-unsafe programming language(such as C or C+),you can expect at least 65%of your security vulnerabilities to be caused by memory unsafety.2.Security issues can happen not only in the kernel,but also in the whole s
3、ystem,which includes the kernel and the system software.Why do we choose rust?The number of vulnerabilities by type in the GNU since 1999(data from:CVE Details)What rust-related things have happened in the kernel since the release of kernel 6.1?Linux 6.1:Officially Adds Support for Rust in the Kerne
4、lKernel internals(kallsyms expansion for Rust symbols,%pA format)Kbuild infrastructure(Rust build rules and support scripts)Rust crates and bindings for initial minimum viable buildRust kernel documentation and samplesPossible to create hello world moduleWhy do we choose rust?Linux 6.1Linux 6.4:What
5、 are the important updates?Linux 6.2:New:#vtable,declare_err!(),dbg!Linux 6.3:New:Some new type,new trait and alloc crate remove borrow moduleLinux 6.4:New :pin-init APIWhy do we choose rust?Using Rust and LFS build linux distroHow to build rust support Kernel?Require:rustc,rust-src(cross-compile co
6、re and alloc),rust-bindgenllvm(clang)make LLVM=1 rustavailablemake CC=clang rustavailableCompile kernelmake LLVM=1(CC=clang)rustavailableenbale Rust support in the General setupOther thinggccrs in developmentHapping HackingUsing Rust and LFS build linux distroBenefits of using LFS to build linuxdist
7、ributionsWhat is LFS?Linux From Scratch(LFS)is a project that provides you with step-by-step instructions for building your own custom Linux system,entirely from source code.Benefits:highly customizablelightweightfull controlSteps:Prepareing for the BuildBuild Cross Toolchain and Temporary ToolsBuil
8、d Basic System Software(73)System ConfigurationMake it bootableUsing Rust and LFS build linux distroUsing Rust and LFS build linux distroNot CustomizableCross compile toolchainsTemptoolsSystem ApplicationKernel and bootCustomizableRust ENVKernel RustsupportRust ApplicationChallenges of using LFS to
9、build linuxdistributions1.A lot of time and effort,as well as a certain level of technical skill and experience.2.Regular manual maintenance of the system,to keep the software and the kernel up to date.3.Solving compatibility or dependency issues that may arise during the compilation process.Using R
10、ust and LFS build linuxdistroPhoto/image/chartdagrs:DAG execution engine is a high-performance multi-task execution engine.Automake the build process using the rust language Using Rust and LFS build linuxdistroAutomake the build process using the rust language Using Rust and LFS build linux distroSt
11、artPrepare HostDownload SourceBuild TemptoolsChrootBuild TemptoolsBuild PackagesConfigureKernel BuildBootNodes:Build PackagesConfigureSwitch to chrootWhat rkos brings us?Rust kernel programingWhat rkos brings us?More system application with rust1.uutils coreutils:a cross-platform reimplementation of
12、 the gnu coreutils in Rust2.ripgrep:ripgrep is faster than grep,ag,glt,grep,ucg,pt,sift3.sudo-rs:A safety oriented and memory safe implementation of sudo and su written in Rust4.ntpd-rs:ntpd is an NTP implememtation written in Rust,with a focus on security and stability5.Trust-DNS:A Rust based DNS c
13、lient,server,and Resolver,built to be safe and secure from the ground up.6.Photo/image/chartuutils/coreutilsWhat rkos bings us?Planing1.Wait for the stable release of dagrs,and then refactor rkos-builder.2.The focus will be on building a clean and reliable foundation environment.3.Support more applications developed by Rust.What rkos bings us?Thank you!