proot: a step forward for qemu user-mode

22
Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion PRoot: a Step Forward for QEMU User-Mode Cédric Vincent Yves Janin Compilation Expertise Center (CEC) STMicroelectronics, Grenoble, France 1 st International QEMU Users Forum (QUF’11) March 18th 2011

Upload: others

Post on 11-Feb-2022

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

PRoot: a Step Forward for QEMUUser-Mode

Cédric Vincent Yves Janin

Compilation Expertise Center (CEC)STMicroelectronics, Grenoble, France

1st International QEMU Users Forum (QUF’11)March 18th 2011

Page 2: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Description

A QEMU Solution for Software DevelopmentQEMU is the right solution for emulating embedded platforms.

Runs fast,Supports several targets: ARM, ST40 (a.k.a. SH4), . . .

QEMU user-modeexecutes one target Linux application on a host Linux system.

PRootcontrols the execution of Linux processes.

Both combineda lightweight emulation environment for Linux applications.

Page 3: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Description

A QEMU Solution for Software DevelopmentQEMU is the right solution for emulating embedded platforms.

Runs fast,Supports several targets: ARM, ST40 (a.k.a. SH4), . . .

QEMU user-modeexecutes one target Linux application on a host Linux system.

PRootcontrols the execution of Linux processes.

Both combineda lightweight emulation environment for Linux applications.

Page 4: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Description

A QEMU Solution for Software DevelopmentQEMU is the right solution for emulating embedded platforms.

Runs fast,Supports several targets: ARM, ST40 (a.k.a. SH4), . . .

QEMU user-modeexecutes one target Linux application on a host Linux system.

PRootcontrols the execution of Linux processes.

Both combineda lightweight emulation environment for Linux applications.

Page 5: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Description

A QEMU Solution for Software DevelopmentQEMU is the right solution for emulating embedded platforms.

Runs fast,Supports several targets: ARM, ST40 (a.k.a. SH4), . . .

QEMU user-modeexecutes one target Linux application on a host Linux system.

PRootcontrols the execution of Linux processes.

Both combineda lightweight emulation environment for Linux applications.

Page 6: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

QEMUlating complex embedded Linux applications

A wide range of use casesAt STMicroelectronics, we use PRoot+QEMU user-mode to:

build Linux packages for an embedded target;run test-suites and validations;and develop Rich Internet Applications (WebKit,FlashPlayer’s VM).

Page 7: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

QEMU system-mode vs user-mode

. . .

QEMU

host kernel

process 1 process N

target kernel

Figure: QEMU system-mode

QEMU

host kernel

process 1

Figure: QEMU user-mode

Page 8: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

QEMU system-mode vs user-mode

. . .

QEMU

host kernel

process 1 process N

target kernel

Figure: QEMU system-mode

QEMU

host kernel

process 1

Figure: QEMU user-mode

Page 9: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Overcoming QEMU user-mode limitations with PRoot

QEMU

host kernel

process 1

PRoot

. . .QEMU

process N

Figure: PRoot + QEMU user-mode

Defining two requirements for PRootR2: New target processes are kept under QEMU.R1: Target processes are confined within the target rootfs.

Page 10: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Overcoming QEMU user-mode limitations with PRoot

QEMU

host kernel

process 1

PRoot

. . .QEMU

process N

Figure: PRoot + QEMU user-mode

Defining two requirements for PRootR2: New target processes are kept under QEMU.

R1: Target processes are confined within the target rootfs.

Page 11: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Overcoming QEMU user-mode limitations with PRoot

QEMU

host kernel

process 1

PRoot

. . .QEMU

process N

Figure: PRoot + QEMU user-mode

Defining two requirements for PRootR2: New target processes are kept under QEMU.R1: Target processes are confined within the target rootfs.

Page 12: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

The ptrace system call

ptrace

ptrace makes it possible for a process to control other pro-cesses. It has several applications:debuggers: GDB, Strace, Ltrace, . . .kernel features: User-Mode Linux, Goanna FS, PRoot, . . .

Page 13: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

QEMU user-mode control flow

QEMU:

host kernel: kernel operation

host syscall

time

target syscall (emulated program)

Figure: QEMU user-mode control flow

Page 14: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

PRoot + QEMU user-mode control flow

QEMU:

PRoot:

host kernel:

translation

kernel operation

host syscall

time

target syscall (emulated program)

Figure: PRoot + QEMU user-mode control flow

open "/lib/ld-linux.so.2"-> open "${target_rootfs}/lib/ld-2.7.so"

exec "/bin/ls"-> exec "qemu-arm", "/bin/ls"

Page 15: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

PRoot + QEMU user-mode control flow

QEMU:

PRoot:

host kernel:

translation

kernel operation

host syscall

time

target syscall (emulated program)

Figure: PRoot + QEMU user-mode control flow

open "/lib/ld-linux.so.2"-> open "${target_rootfs}/lib/ld-2.7.so"

exec "/bin/ls"-> exec "qemu-arm", "/bin/ls"

Page 16: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

PRoot + QEMU user-mode control flow

QEMU:

PRoot:

host kernel:

translation

kernel operation

host syscall

time

target syscall (emulated program)

Figure: PRoot + QEMU user-mode control flow

open "/lib/ld-linux.so.2"-> open "${target_rootfs}/lib/ld-2.7.so"

exec "/bin/ls"-> exec "qemu-arm", "/bin/ls"

Page 17: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

PRoot + QEMU user-mode vs QEMU system-mode

Table: PRoot + QEMU user-mode vs QEMU system-mode speed-up

Build step Perl v5.10.0 Coreutils v6.12archive extraction 3.6× faster 2.7× fasterconfiguration 2.0× faster 4.0× fasterbuild 2.9× faster 3.5× fastervalidation 4.1× faster 3.6× faster

Annex A

Page 18: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Typical example

You just have to specify the QEMU and the target rootfs:

$ proot -Q qemu-arm ./armedslack-12.2

From that point every process is QEMUlated:

$ file ‘which file‘/usr/bin/file: ELF 32-bit LSB executable, ARM [...]

The build and validation of a target package is straight forward,no need for cross-compilation support:

$ tar -xf perl-5.10.0.tar.gz; cd perl-5.10.0$ ./Configure -de$ make -j 4$ make -j 4 test

Page 19: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Typical example

You just have to specify the QEMU and the target rootfs:

$ proot -Q qemu-arm ./armedslack-12.2

From that point every process is QEMUlated:

$ file ‘which file‘/usr/bin/file: ELF 32-bit LSB executable, ARM [...]

The build and validation of a target package is straight forward,no need for cross-compilation support:

$ tar -xf perl-5.10.0.tar.gz; cd perl-5.10.0$ ./Configure -de$ make -j 4$ make -j 4 test

Page 20: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Typical example

You just have to specify the QEMU and the target rootfs:

$ proot -Q qemu-arm ./armedslack-12.2

From that point every process is QEMUlated:

$ file ‘which file‘/usr/bin/file: ELF 32-bit LSB executable, ARM [...]

The build and validation of a target package is straight forward,no need for cross-compilation support:

$ tar -xf perl-5.10.0.tar.gz; cd perl-5.10.0$ ./Configure -de$ make -j 4$ make -j 4 test

Page 21: PRoot: a Step Forward for QEMU User-Mode

Enhancing QEMU in user-mode PRoot: Execution control and Pseudo-Root FS in user-mode Conclusion

Conclusion

PRoot + QEMU user-mode: an extended user-mode;no setup, no configuration, no administrative privilege;and compatible with any version of QEMU.

PRoot soon to be publishedGPL v2+ licensehttp://proot.me

Any feedback and suggestion welcomed! Thanks!

Page 22: PRoot: a Step Forward for QEMU User-Mode

Annex A: Comparison with other tools

Back

Table: Testing SB2+QEMU user-mode vs PRoot+QEMU user-mode

Package SB2 v2.2 PRoot v0.5 system-modePerl v5.10.0 99.6% 99.6% 99.8%GNU Coreutils v6.12 94.9% 97.3% 96.7%

We tested many tools, but only two survive the tests above.We did not consider solutions with administrative privilege.Both PRoot and SB2 have robust path canonicalization al-gorithms.PRoot and SB2 differ in many aspects (design, usage, . . . ).