🇰🇷 한글 설명
Linux 커널에서 BPF LSM이 초기화되지 않은 상태로 CONFIG_BPF_LSM이 활성화되어 있을 때, BPF_MAP_TYPE_INODE_STORAGE 맵 생성을 허용하여 발생하는 취약점입니다. 이로 인해 커널 내부의 RCU 콜백 포인터가 잘못된 메모리 주소를 참조하게 되어 시스템이 즉시 패닉(Kernel Panic) 상태에 빠질 수 있습니다.
💡 쉬운 설명
리눅스 시스템의 특정 기능을 사용할 때, 준비되지 않은 상태에서 잘못된 메모리 주소를 건드려 컴퓨터가 갑자기 멈추거나 꺼지는 현상이 발생할 수 있습니다. 이는 시스템의 안정성을 해치는 심각한 오류를 유발합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Reject BPF_MAP_TYPE_INODE_STORAGE creation if BPF LSM is uninitialized
When CONFIG_BPF_LSM=y is set, BPF inode storage maps
(BPF_MAP_TYPE_INODE_STORAGE) are compiled into the kernel. However,
if the BPF LSM is not explicitly enabled at boot time (e.g. omitted
from the "lsm=" boot parameter), lsm_prepare() is never executed for
the BPF LSM.
Consequently, the BPF inode security blob offset
(bpf_lsm_blob_sizes.lbs_inode) is never initialized and remains at
its default compiled size of 8 bytes instead of being updated to a
valid offset past the reserved struct rcu_head (typically 16 bytes
or more).
When a privileged user creates and updates a BPF_MAP_TYPE_INODE_STORAGE
map, bpf_inode() evaluates inode->i_security + 8. This erroneously
aliases the struct rcu_head.func callback pointer at the beginning
of the inode->i_security blob. During subsequent map element cleanup
or inode destruction, writing NULL to owner_storage clears the queued
RCU callback pointer. When rcu_do_batch() later executes the queued
callback, it attempts an instruction fetch at address 0x0, triggering
an immediate kernel panic.
Fix this by introducing a global bpf_lsm_initialized boolean flag
marked with __ro_after_init. Set this flag to true inside bpf_lsm_init()
when the LSM framework successfully registers the BPF LSM. Gate map
allocation in inode_storage_map_alloc() on this flag, returning
-EOPNOTSUPP if the BPF LSM is in turn uninitialized.
This fail-fast approach prevents userspace from allocating inode
storage maps when the supporting BPF LSM infrastructure is absent,
avoiding zombie map states.
📍 영향받는 시스템
CONFIG_BPF_LSM=y 설정이 되어 있으나 lsm= 파라미터에 BPF LSM이 포함되지 않은 Linux Kernel
⚔️ 공격 벡터
권한이 있는 사용자가 BPF_MAP_TYPE_INODE_STORAGE 맵을 생성하고 업데이트하여 커널 패닉 유도
🛡️ 대응 방법
커널 패치를 적용하여 BPF LSM 초기화 여부를 확인하는 플래그를 도입하고, 초기화되지 않은 경우 맵 생성을 차단해야 함
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전인지 배포판 보안 공지를 통해 확인하십시오.