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 を利用する Google Pixel デバイス(Google Pixel 6 ~ 9)に実装されています。Arm は、r54p2 リリースの Documentation/ioctl-categories.rst で IOCTL の公式な分類を提供しています。このリストは、今後のドライバ リリースでも引き続き維持されます。
テスト
カーネル ドライバの動作を確認するには、次の操作を行います。
ドライバが正当なアプリケーション IOCTL をブロックしていないこと、
信頼できないアプリケーションが計測と制限付き IOCTL を実行できないことを確認します。