skip to main content
10.1145/3374664.3375734acmconferencesArticle/Chapter ViewAbstractPublication PagescodaspyConference Proceedingsconference-collections
research-article

PESC: A Per System-Call Stack Canary Design for Linux Kernel

Published: 16 March 2020 Publication History

Abstract

Stack canary is the most widely deployed defense technique against stack buffer overflow attacks. However, since its proposition, the design of stack canary has very few improvements during the past 20 years, making it vulnerable to new and sophisticated attacks. For example, the ARM64 Linux kernel is still adopting the same design with StackGuard, using one global canary for the whole kernel. The x86_64 Linux kernel leverages a better design by using a per-task canary for different threads. Unfortunately, both of them are vulnerable to kernel memory leaks. Using the memory leak bugs or hardware side-channel attacks, e.g., Meltdown or Spectre, attackers can easily peek the kernel stack canary value, thus bypassing the protection. To address this issue, we proposed a fine-grained design of the kernel stack canary named PESC, standing for Per-System-Call Canary, which changes the kernel canary value on the system call basis. With PESC, attackers cannot accumulate any knowledge of prior canary across multiple system calls. In other words, PESC is resilient to memory leaks. Our key observation is that before serving a system call, the kernel stack is empty and there are no residual canary values on the stack. As a result, we can directly change the canary value on system call entry without the burden of tracking and updating old canary values on the kernel stack. Moreover, to balance the performance as well as the security, we proposed two PESC designs: one relies on the performance monitor counter register, termed as PESC-PMC, while the other one uses the kernel random number generator, denoted as PESC-RNG. We implemented both PESC-PMC and PESC-RNG on the real-world hardware, using HiKey960 board for ARM64 and Intel i7-7700 for x86_64. The synthetic benchmark and SPEC CPU2006 experimental results show that the performance overhead introduced by PESC-PMC and PESC-RNG on the whole system is less than 1%.

References

[1]
2011. Approximate Overhead of System Calls. https://www.ibm.com/ developerworks/community/blogs/kevgrig/entry/approximate_overhead_of_ system_calls9?lang=en. (2011).
[2]
2017. byte-unixbenchs. https://github.com/kdlucas/byte-unixbench. (2017).
[3]
2018. Exploit Mitigation Techniques - Stack Canaries. https://0x00sec.org/t/ exploit-mitigation-techniques-stack-canaries/5085. (2018).
[4]
2018. Intel Digital Random Number Generator (DRNG) Software Implementation Guide. https://software.intel.com/en-us/articles/intel-digital-random-numbergenerator- drng-software-implementation-guide. (2018).
[5]
2018. Issue 1657: Linux: semi-arbitrary task stack read on ARM64 (and x86) via /proc/pid/stack. https://bugs.chromium.org/p/project-zero/issues/detail?id=1657. (2018).
[6]
2019. 2PAC 2Furious: Envisioning an iOS Compromise in 2019. https://downloads.immunityinc.com/infiltrate2019-slidepacks/marco-grassiliang- chen-2pac-2furious/infiltrate19_final.pdf. (2019).
[7]
2019. Arm Architecture Reference Manual, Issue E.a. https://developer.arm.com/ docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-aarchitecture- profile. (2019).
[8]
2019. Cycle Count Register. https://developer.arm.com/docs/ddi0433/ a/performance-monitoring-unit/performance-monitoring-registerdescriptions/ performance-monitor-control-register. (2019).
[9]
2019. Function prologue. https://en.wikipedia.org/wiki/Function_prologue. (2019).
[10]
2019. HiKey960 board. https://source.android.com/setup/build/devices. (2019).
[11]
2019. Intel 64 and IA-32 Architectures Software Developerâ's Manual. https://software.intel.com/sites/default/files/managed/39/c5/325462-sdmvol- 1--2abcd-3abcd.pdf. (2019).
[12]
2019. Issue 1759: KVM: uninitialized memory leak in kvm_inject_page_fault. https://bugs.chromium.org/p/project-zero/issues/detail?id=1759. (2019).
[13]
2019. Issues - project zero. https://bugs.chromium.org/p/projectzero/ issues/list?can=1&q=stack+overflow&colspec=ID+Status+Restrict+ Reported+Vendor+Product+Finder+Summary&num=100. (2019).
[14]
2019. Lists of instruction latencies, throughputs and micro-operation breakdowns for Intel, AMD, and VIA CPUs. https://www.agner.org/optimize/instruction_ tables.pdf. (2019).
[15]
2019. Microsoft /GS(Buffer Security Check). https://docs.microsoft.com/enus/ cpp/build/reference/gs-buffer-security-check?redirectedfrom=MSDN& view=vs-2019. (2019).
[16]
2019. Morris Worm. https://en.wikipedia.org/wiki/Morris_worm. (2019).
[17]
2019. Performance monitoring register descriptions. https://developer.arm. com/docs/ddi0433/a/performance-monitoring-unit/performance-monitoringregister- descriptions. (2019).
[18]
2019. Return-oriented programming - Wikipedia. https://en.wikipedia.org/wiki/ Return-oriented_programming. (2019).
[19]
2019. SPEC CPU 2006. http://www.spec.org/cpu2006/. (2019).
[20]
2019. STACKPROTECTOR_STRONG. https://elixir.bootlin.com/linux/v5.0/ source/arch/Kconfig#L473. (2019).
[21]
Steven Alexander. 2005. Defeating compiler-level buffer overflow protection. The USENIX Magazine; login (2005).
[22]
Ahmed M Azab, Peng Ning, Jitesh Shah, Quan Chen, Rohan Bhutkar, Guruprasad Ganesh, Jia Ma, and Wenbo Shen. 2014. Hypervision across worlds: Real-time kernel protection from the arm trustzone secure world. In Proceedings of the 2014 ACM SIGSAC Conference on Computer and Communications Security. ACM, 90--102.
[23]
Brian Belleville, Wenbo Shen, Stijn Volckaert, Ahmed M Azab, and Michael Franz. 2019. KALD: Detecting Direct Pointer Disclosure Vulnerabilities. IEEE Transactions on Dependable and Secure Computing (2019).
[24]
Bruno Bierbaumer, Julian Kirsch, Thomas Kittel, Aurélien Francillon, and Apostolis Zarras. 2018. Smashing the Stack Protector for Fun and Profit. In IFIP International Conference on ICT Systems Security and Privacy Protection. Springer, 293--306.
[25]
Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, and Dan Boneh. 2014. Hacking blind. In 2014 IEEE Symposium on Security and Privacy. IEEE, 227--242.
[26]
Crispin Cowan, Steve Beattie, Ryan Finnin Day, Calton Pu, Perry Wagle, and Erik Walthinsen. 1999. Protecting systems from stack smashing attacks with StackGuard. In Linux Expo.
[27]
Crispan Cowan, Calton Pu, Dave Maier, Jonathan Walpole, Peat Bakke, Steve Beattie, Aaron Grier, Perry Wagle, Qian Zhang, and Heather Hinton. 1998. Stackguard: Automatic adaptive detection and prevention of buffer-overflow attacks. In USENIX Security Symposium, Vol. 98. San Antonio, TX, 63--78.
[28]
Crispin Cowan, F Wagle, Calton Pu, Steve Beattie, and Jonathan Walpole. 2000. Buffer overflows: Attacks and defenses for the vulnerability of the decade. In Proceedings DARPA Information Survivability Conference and Exposition. DISCEX'00, Vol. 2. IEEE, 119--129.
[29]
Yu Ding, Zhuo Peng, Yuanyuan Zhou, and Chao Zhang. 2014. Android low entropy demystified. In 2014 IEEE International Conference on Communications (ICC). IEEE, 659--664.
[30]
Hiroaki Etoh. 2019. GCC extension for protecting applications from stack-smashing attacks (ProPolice)(2003). URL http://www. trl. ibm. com/projects/security/ssp (2019).
[31]
William H Hawkins, Jason D Hiser, and JackWDavidson. 2016. Dynamic canary randomization for improved software security. In Proceedings of the 11th Annual Cyber and Information Security Research Conference. ACM, 9.
[32]
Paul Kocher, Jann Horn, Anders Fogh, Daniel Genkin, Daniel Gruss, Werner Haas, Mike Hamburg, Moritz Lipp, Stefan Mangard, Thomas Prescher, Michael Schwarz, and Yuval Yarom. 2019. Spectre Attacks: Exploiting Speculative Execution. In 40th IEEE Symposium on Security and Privacy (S&P'19).
[33]
Moritz Lipp, Michael Schwarz, Daniel Gruss, Thomas Prescher, Werner Haas, Anders Fogh, Jann Horn, Stefan Mangard, Paul Kocher, Daniel Genkin, Yuval Yarom, and Mike Hamburg. 2018. Meltdown: Reading Kernel Memory from User Space. In 27th USENIX Security Symposium (USENIX Security 18).
[34]
Chi-Keung Luk, Robert Cohn, Robert Muth, Harish Patil, Artur Klauser, Geoff Lowney, Steven Wallace, Vijay Janapa Reddi, and Kim Hazelwood. 2005. Pin: building customized program analysis tools with dynamic instrumentation. In Acm sigplan notices, Vol. 40. ACM, 190--200.
[35]
Hector Marco-Gisbert and Ismael Ripoll. 2013. Preventing brute force attacks against stack canary protection on networking servers. In 2013 IEEE 12th International Symposium on Network Computing and Applications. IEEE, 243--250.
[36]
Héctor Marco-Gisbert and Ismael Ripoll-Ripoll. 2019. SSPFA: effective stack smashing protection for Android OS. International Journal of Information Security (2019), 1--14.
[37]
Aleph One. 1996. Smashing the stack for fun and profit. Phrack magazine 7, 49 (1996), 14--16.
[38]
Theofilos Petsios, Vasileios P Kemerlis, Michalis Polychronakis, and Angelos D Keromytis. 2015. Dynaguard: Armoring canary-based protections against bruteforce attacks. In Proceedings of the 31st Annual Computer Security Applications Conference. ACM, 351--360.
[39]
Raoul Strackx, Yves Younan, Pieter Philippaerts, Frank Piessens, Sven Lachmund, and Thomas Walter. 2009. Breaking the memory secrecy assumption. In Proceedings of the Second European Workshop on System Security. ACM, 1--8.
[40]
Laszlo Szekeres, Mathias Payer, Lenx Tao Wei, and R Sekar. 2014. Eternal war in memory. IEEE Security & Privacy 12, 3 (2014), 45--53.
[41]
Laszlo Szekeres, Mathias Payer, Tao Wei, and Dawn Song. 2013. Sok: Eternal war in memory. In 2013 IEEE Symposium on Security and Privacy. IEEE, 48--62.
[42]
Perry Wagle, Crispin Cowan, et al. 2003. Stackguard: Simple stack smash protection for gcc. In Proceedings of the GCC Developers Summit. Citeseer, 243--255.
[43]
Zhilong Wang, Xuhua Ding, Chengbin Pang, Jian Guo, Jun Zhu, and Bing Mao. 2018. To detect stack buffer overflow with polymorphic canaries. In 2018 48th Annual IEEE/IFIP International Conference on Dependable Systems and Networks (DSN). IEEE, 243--254.
[44]
Wei Wu, Yueqi Chen, Xinyu Xing, and Wei Zou. 2019. {KEPLER}: Facilitating Control-flow Hijacking Primitive Evaluation for Linux Kernel Vulnerabilities. In 28th {USENIX} Security Symposium ({USENIX} Security 19). 1187--1204.
[45]
A Zabrocki. 2010. Scraps of notes on remote stack overflow exploitation. Phrack 63, 15 (2010).
[46]
Tong Zhang, Wenbo Shen, Dongyoon Lee, Changhee Jung, Ahmed M Azab, and Ruowen Wang. 2019. PeX: A Permission Check Analysis Framework for Linux Kernel. In 28th USENIX Security Symposium 2019. 1205--1220.
[47]
Jun Zhu, Weiping Zhou, Zhilong Wang, Dongliang Mu, and Bing Mao. 2017. Diffguard: Obscuring sensitive information in canary based protections. In International Conference on Security and Privacy in Communication Systems. Springer, 738--751.

Cited By

View all

Index Terms

  1. PESC: A Per System-Call Stack Canary Design for Linux Kernel

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    CODASPY '20: Proceedings of the Tenth ACM Conference on Data and Application Security and Privacy
    March 2020
    392 pages
    ISBN:9781450371070
    DOI:10.1145/3374664
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 16 March 2020

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. buffer overflow
    2. kernel
    3. stack canary
    4. system call

    Qualifiers

    • Research-article

    Funding Sources

    • Zhejiang Key R&D Plan
    • the National Natural Science Foundation of China

    Conference

    CODASPY '20
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 149 of 789 submissions, 19%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)23
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 03 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media