Android 16 QPR2에서는 커널 드라이버를 강화하기 위해 SELinux 매크로를 추가합니다. 이 매크로는 지원 중단된 IOCTL이나 커널 드라이버 개발용 IOCTL과 같은 제한된 IOCTL을 프로덕션에서 차단합니다. 또한 드라이버 프로파일링의 IOCTL을 셸 또는 디버깅 가능한 앱으로 제한합니다. 이 매크로를 사용하여 기기의 보안을 강화하세요.
구현
세부적인 syscall 필터링으로 기기를 강화하려면 기기의 SEPolicy에서 set_xperm_filter 매크로를 호출하세요. 예를 들면 다음과 같습니다.
# set_xperm_filter(target_context, allowed_target, unpriv_ioctls, restricted_ioctls, instrumentation_ioctls)
# Allow targets to harden their IOCTL interfaces by specifying
# unprivileged, blocked, and instrumentation-specific IOCTLs for appdomain.
#
# Parameters:
# target_context: The target context to apply the filter to.
# allowed_target: Additional `appdomain` target to exempt from hardened policy.
# Allows for an allowlist of services, or gating by a target SDK.
# unpriv_ioctls: IOCTLs to allow across appdomain.
# restricted_ioctls: IOCTLs to deny across appdomain.
# instrumentation_ioctls: IOCTLs intended to be used in development.
# IOCTLs will be allowed from `shell` or `debuggable` applications.
define(`unpriv_gpu_ioctls', `0x0000, 0x0001, 0x0002')
define(`restricted_ioctls', `0x1110, 0x1111, 0x1112')
define(`instrumentation_gpu_ioctls', `0x2220, 0x2221, 0x2222')
set_xperm_filter(
gpu_device,
untrusted_app_sdk_gate,
unpriv_ioctls,
restricted_ioctls,
instrumentation_ioctls)
set_xperm_filter의 매크로 정의는 system/sepolicy/public/te_macros에 있습니다.
이 매크로는 unpriv_ioctls를 허용하고 restricted_ioctls를 차단하며 instrumentation_ioctls를 shell 프로세스 또는 debuggable 앱으로 제한합니다. 이 필터는 지정된 target_sdk에서 시작하는 애플리케이션에 적용됩니다.
이 기능은 Mali GPU를 사용하는 Pixel 기기(Pixel 6~9)에 구현되었습니다. Arm은 r54p2 출시의 Documentation/ioctl-categories.rst에 IOCTL의 공식 분류를 제공했습니다.
이 목록은 향후 드라이버 출시에서도 계속 유지됩니다.
테스트
커널 드라이버의 동작을 확인하려면 다음을 실행하세요.
드라이버가 합법적인 애플리케이션 IOCTL을 차단하지 않는지 확인합니다.
신뢰할 수 없는 애플리케이션이 계측 및 제한된 IOCTL을 실행할 수 없는지 확인합니다.