🇰🇷 한글 설명
Linux 커널의 writeback 과정 중 inode_switch_wbs_work_fn() 함수에서 Use-After-Free 취약점이 발견되었습니다. 특정 조건에서 작업(work)이 대기 중임에도 불구하고 관련 객체가 메모리에서 해제되어 시스템 불안정이나 보안 문제를 일으킬 수 있습니다.
💡 쉬운 설명
컴퓨터가 해야 할 일을 목록에 적어두었는데, 목록이 비어있다고 착각하여 실제 작업이 끝나기도 전에 메모리에서 해당 정보를 지워버리는 문제입니다. 이로 인해 시스템이 잘못된 메모리 주소를 참조하여 오류가 발생하거나 해킹에 이용될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
writeback: Fix use after free in inode_switch_wbs_work_fn()
inode_switch_wbs_work_fn() has a loop like:
wb_get(new_wb);
while (1) {
list = llist_del_all(&new_wb->switch_wbs_ctxs);
/* Nothing to do? */
if (!list)
break;
... process the items ...
}
Now adding of items to the list looks like:
wb_queue_isw()
if (llist_add(&isw->list, &wb->switch_wbs_ctxs))
queue_work(isw_wq, &wb->switch_work);
Because inode_switch_wbs_work_fn() loops when processing isw items, it
can happen that wb->switch_work is pending while wb->switch_wbs_ctxs is
empty. This is a problem because in that case wb can get freed (no isw
items -> no wb reference) while the work is still pending causing
use-after-free issues.
We cannot just fix this by cancelling work when freeing wb because that
could still trigger problematic 0 -> 1 transitions on wb refcount due to
wb_get() in inode_switch_wbs_work_fn(). It could be all handled with
more careful code but that seems unnecessarily complex so let's avoid
that until it is proven that the looping actually brings practical
benefit. Just remove the loop from inode_switch_wbs_work_fn() instead.
That way when wb_queue_isw() queues work, we are guaranteed we have
added the first item to wb->switch_wbs_ctxs and nobody is going to
remove it (and drop the wb reference it holds) until the queued work
runs.
📍 영향받는 시스템
Linux Kernel (writeback 관련 기능이 포함된 버전)
⚔️ 공격 벡터
특정 파일 시스템 작업 및 inode 전환 과정을 유도하여 메모리 해제 후 참조(Use-After-Free) 유발
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 inode_switch_wbs_work_fn()의 루프 로직 수정 사항을 반영해야 합니다.
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전 이상인지 확인합니다.