🇰🇷 한글 설명
Linux 커널 XFS 파일 시스템에서 확장 속성(xattr) 저장 시 사용 가능한 공간 맵(freemap)을 잘못 관리하여, 엔트리가 충돌하고 새로운 데이터가 기존 데이터 위에 덮어써지면서 데이터 손실이 발생할 수 있는 버그입니다.
💡 쉬운 설명
파일에 부가 정보를 저장할 때 빈 공간 목록을 제대로 정리하지 않아서, 새로운 정보가 기존 정보를 지워버릴 수 있습니다. 시스템 운영자가 파일에 속성을 추가할 때 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
xfs: delete attr leaf freemap entries when empty
Back in commit 2a2b5932db6758 ("xfs: fix attr leaf header freemap.size
underflow"), Brian Foster observed that it's possible for a small
freemap at the end of the end of the xattr entries array to experience
a size underflow when subtracting the space consumed by an expansion of
the entries array. There are only three freemap entries, which means
that it is not a complete index of all free space in the leaf block.
This code can leave behind a zero-length freemap entry with a nonzero
base. Subsequent setxattr operations can increase the base up to the
point that it overlaps with another freemap entry. This isn't in and of
itself a problem because the code in _leaf_add that finds free space
ignores any freemap entry with zero size.
However, there's another bug in the freemap update code in _leaf_add,
which is that it fails to update a freemap entry that begins midway
through the xattr entry that was just appended to the array. That can
result in the freemap containing two entries with the same base but
different sizes (0 for the "pushed-up" entry, nonzero for the entry
that's actually tracking free space). A subsequent _leaf_add can then
allocate xattr namevalue entries on top of the entries array, leading to
data loss. But fixing that is for later.
For now, eliminate the possibility of confusion by zeroing out the base
of any freemap entry that has zero size. Because the freemap is not
intended to be a complete index of free space, a subsequent failure to
find any free space for a new xattr will trigger block compaction, which
regenerates the freemap.
It looks like this bug has been in the codebase for quite a long time.
📍 영향받는 시스템
XFS 파일 시스템을 사용하는 모든 Linux 커널 버전 (패치 적용 전)
⚔️ 공격 벡터
로컬 접근자가 XFS 파일 시스템의 파일에 대해 반복된 확장 속성(xattr) 설정 작업 수행
🛡️ 대응 방법
Linux 커널을 패치된 버전 이상으로 업그레이드하거나 해당 xfs freemap 수정 커밋 적용
🔧 검증 코드
위 명령어가 해당 커밋(commit 2a2b5932db6758의 수정 사항)을 찾으면 패치가 적용된 것이고, 'Patch not applied'가 출력되면 취약점이 존재하는 상태입니다.
git log --oneline --all | grep -i 'delete attr leaf freemap' || echo 'Patch not applied'