🇰🇷 한글 설명
Linux 커널의 DAMON 구성 요소에서 샘플링 또는 집계 간격을 0으로 설정하거나 매우 높게 설정할 경우 발생하는 취약점입니다. 이로 인해 0으로 나누기 오류(Divide-by-zero)가 발생하여 시스템이 충돌하거나, 배열 범위를 벗어난 메모리 접근(Out-of-bounds access)이 발생할 수 있습니다.
💡 쉬운 설명
시스템의 메모리 사용량을 모니터링하는 기능에서 설정값을 잘못 입력하면 컴퓨터가 갑자기 멈추거나 오류가 발생할 수 있는 문제입니다. 특히 숫자를 0으로 설정하거나 너무 큰 값을 넣었을 때 시스템이 계산을 못 하고 고장 나는 현상입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/damon/ops-common: handle extreme intervals in damon_hot_score()
Fix three issues in damon_hot_score() that comes from wrong handling of
extreme (zero or too high) monitoring intervals user setup.
When the user sets sampling interval zero, damon_max_nr_accesses(), which
is called from damon_hot_score(), causes a divide-by-zero. Needless to
say, it is a problem.
When the user sets the aggregation interval zero, the function returns
zero. It is wrong, since the real maximum nr_acceses in the setup should
be one. Worse yet, it can cause another divide-by-zero from its caller,
damon_hot_score(), since it uses damon_max_nr_accesses() return value as a
denominator.
When the user sets the aggregation interval very high, damon_hot_score()
could return a value out of [0, DAMOS_MAX_SCORE] range. Since the return
value is used as an index to the regions_score_histogram array, which is
DAMOS_MAX_SCORE+1 size, it causes out of bounds array access.
The issues can be relatively easily reproduced like below. The sysfs
write permission is required, though.
# ./damo start --damos_action lru_prio --damos_quota_space 100M \
--damos_quota_interval 1s
# cd /sys/kernel/mm/damon/admin/kdamonds/0
# echo 0 > contexts/0/monitoring_attrs/intervals/sample_us
# echo 0 > contexts/0/monitoring_attrs/intervals/aggr_us
# echo commit > state
# dmesg
[...]
[ 131.329762] Oops: divide error: 0000 [#1] SMP NOPTI
[...]
[ 131.336089] RIP: 0010:damon_hot_score+0x27/0xd0
[...]
Fix the divide-by-zero intervals problems by explicitly handling the zero
intervals in damon_max_nr_accesses(). Fix the out-of-bound array access
by applying [0, DAMOS_MAX_SCORE] bounds before returning from
damon_hot_score().
The issue was discovered [1] by Sashiko.
📍 영향받는 시스템
DAMON 기능이 활성화된 Linux 커널 버전
⚔️ 공격 벡터
sysfs 인터페이스를 통해 모니터링 간격(sample_us, aggr_us)을 0 또는 극단적인 값으로 설정하여 공격
🛡️ 대응 방법
DAMON 관련 패치가 적용된 최신 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전인지 배포판 보안 공지를 통해 확인