🇰🇷 한글 설명
Linux 커널의 mm/page_alloc에서 init_on_free 설정 시 huge zero folio의 태그 초기화가 누락되는 취약점입니다. 이로 인해 메모리 태그가 제대로 초기화되지 않아 이전 데이터의 태그 정보가 노출될 수 있습니다.
💡 쉬운 설명
메모리를 깨끗하게 비우는 과정에서 특정 대용량 메모리 영역의 '보안 태그'가 제대로 지워지지 않는 문제입니다. 이로 인해 이전에 사용하던 메모리의 흔적이 남아 보안에 영향을 줄 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/page_alloc: fix initialization of tags of the huge zero folio with init_on_free
__GFP_ZEROTAGS semantics are currently a bit weird, but effectively this
flag is only ever set alongside __GFP_ZERO and __GFP_SKIP_KASAN.
If we run with init_on_free, we will zero out pages during
__free_pages_prepare(), to skip zeroing on the allocation path.
However, when allocating with __GFP_ZEROTAG set, post_alloc_hook() will
consequently not only skip clearing page content, but also skip clearing
tag memory.
Not clearing tags through __GFP_ZEROTAGS is irrelevant for most pages that
will get mapped to user space through set_pte_at() later: set_pte_at() and
friends will detect that the tags have not been initialized yet
(PG_mte_tagged not set), and initialize them.
However, for the huge zero folio, which will be mapped through a PMD
marked as special, this initialization will not be performed, ending up
exposing whatever tags were still set for the pages.
The docs (Documentation/arch/arm64/memory-tagging-extension.rst) state
that allocation tags are set to 0 when a page is first mapped to user
space. That no longer holds with the huge zero folio when init_on_free is
enabled.
Fix it by decoupling __GFP_ZEROTAGS from __GFP_ZERO, passing to
tag_clear_highpages() whether we want to also clear page content.
Invert the meaning of the tag_clear_highpages() return value to have
clearer semantics.
Reproduced with the huge zero folio by modifying the check_buffer_fill
arm64/mte selftest to use a 2 MiB area, after making sure that pages have
a non-0 tag set when freeing (note that, during boot, we will not actually
initialize tags, but only set KASAN_TAG_KERNEL in the page flags).
$ ./check_buffer_fill
1..20
...
not ok 17 Check initial tags with private mapping, sync error mode and mmap memory
not ok 18 Check initial tags with private mapping, sync error mode and mmap/mprotect memory
...
This code needs more cleanups; we'll tackle that next, like
decoupling __GFP_ZEROTAGS from __GFP_SKIP_KASAN.
[
[email protected]: s/__GPF_ZERO/__GFP_ZERO/, per David]
📍 영향받는 시스템
Linux Kernel (huge zero folio 및 init_on_free 기능 사용 시)
⚔️ 공격 벡터
메모리 태그 정보 노출을 통한 정보 유출 또는 메모리 보호 메커니즘 우회
🛡️ 대응 방법
커널 패치를 적용하여 __GFP_ZEROTAGS와 __GFP_ZERO의 동작을 분리하고 태그 초기화 로직을 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 패치 버전인지 확인합니다.