Android: protecting the kernel

本文探讨了Linux的内置安全机制,如地址空间隔离、权限控制及SELinux等,并分析了内核漏洞分类与利用缓解策略,如硬化用户复制、堆栈保护与KASLR。同时,提供了安全编码建议与驱动代码质量提升方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Linux内置安全机制

  • Address space separation/process isolation
  • unix permissions
  • DAC capabilities
  • SELinux
  • seccomp
  • namespaces

内核Top 漏洞分类(按数量排序包括Core kernel 与 Vendor drivers,数据日期January 2014 -> April 2016)

  1. missing/incorrect bounds check
  2. null pointer defeference
  3. information leak
  4. missing permission check
  5. use after free
  6. race condition
  7. memory corruption(other)
  8. other
  9. integer overflow
  10. uninitialized data

利用缓解,安全机制- missing/incorrect bounds check(Landing in upstream kernel!)

  • Hardened usercopy
    • Protect against incorrect bounds checking in copy_*_user()
  • PAN emulation
    • Protect against kernel access to userspace bypassing hardened usercopy changes.
  • Stack protector strong
  • protects against stack buffer overflows
  • KASLR (arm64 android-4.4 kernel)
  • Makes code reuse attacks probabilistic
  • PXN - make userspace non-executable for the kernel
    • Protects against ret2user attacks
  • RODATA - mark kernel memory as read-only/no-execute
    • Makes code non-writeable, and data non-executable

漏洞利用缓解机制 - null pointer dereference

  • CONFIG_LSM_MMAP_MIN_ADDR
    • Make null pointer dereference unexploitable (just crash)
  • PAN emulation also make null pointer
    • dereference non-exploitable

一些安全建议

Android主线上的内核代码质量要优于厂商驱动代码:
- 厂商如何提升驱动代码安全质量? Step2
- Compiler changes e.g. integer overflow checking(clang 3.5+与gcc 5.0+都有integer overflow 检测)
- Scripts e.g. checkpatch.pl (checkpatch.pl可执行质量和简单漏洞检测)
- Runtime changes - e.g. PAN enforce proper use of copy_*_user() (Privileged Access Never)
- KASAN (内存错误检测)
- Constification (const声明)

利用缓解 - 减少攻击面(Linux权限模型,与SEAndroid策略配置)Setp1

  • Restrict access to perf(限制perf访问)
    • Access to perf_event_open() is disabled by default.
    • Developers may re-enable access via debug shell
  • Remove access to debugfs (限制debugfs访问,Android N完全禁止APP访问)
    • All app access to debugfs removed in N
  • Remove default access to /sys (白名单限制/sys访问)
    • App access to files in /sys must be whitelisted
  • Seccomp required for all devices (minijail shoutout!)

驱动代码安全质量控制:

    1. 安全编码规范,动静态安全检查(KASAN,checkpatch.pl等),安全编译选项
    2. 打开所有漏洞利用缓解机制
    3. 通过SELinux策略与Linux权限控制,减小驱动接口攻击面

转载于:https://www.cnblogs.com/gm-201705/p/9863966.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值