🇰🇷 한글 설명
Linux 커널의 tun_dst_unclone 함수에서 발생하던 잘못된 memcpy 오버플로우 경고 문제를 해결했습니다. kmalloc_flex()를 통해 할당된 구조체의 크기 계산 방식이 컴파일러의 보안 검사(fortification)와 충돌하여 실제로는 안전함에도 오버플로우로 오인되는 현상이 있었습니다.
💡 쉬운 설명
컴퓨터가 데이터를 복사할 때, 실제로는 공간이 충분함에도 불구하고 계산 실수로 인해 데이터가 넘칠 것 같다고 잘못 판단하여 경고를 발생시키는 버그입니다. 이로 인해 시스템이 비정상적으로 동작하거나 보안 검사 기능이 오작동할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
net: dst_metadata: fix false-positive memcpy overflow in tun_dst_unclone
kmalloc_flex() in metadata_dst_alloc() sets __counted_by for the
structure to the options_len, which is then initialized to zero.
Later, we're initializing the structure by copying the tunnel info
together with the options, and this triggers a warning for a potential
memcpy overflow, since the compiler estimates that the options can't
fit into the structure, even though the memory for them is actually
allocated.
memcpy: detected buffer overflow: 104 byte write of buffer size 96
WARNING: CPU: X PID: Y at lib/string_helpers.c:1036 __fortify_report
skb_tunnel_info_unclone+0x179/0x190
geneve_xmit+0x7fe/0xe00
The issue is triggered when built with clang and source fortification.
Fix that by doing the copy in two stages: first - the main data with
the options_len, then the options. This way the correct length should
be known at the time of the copy.
It would be better if the options_len never changed after allocation,
but the allocation code is a little separate from the initialization
and it would be awkward and potentially dangerous to return a struct
with options_len set to a non-zero value from the metadata_dst_alloc().
Another option would be to use ip_tunnel_info_opts_set(), but it is
doing too many unnecessary operations for the use case here.
📍 영향받는 시스템
Clang 컴파일러와 소스 강화(source fortification) 기능이 활성화된 Linux 커널
⚔️ 공격 벡터
직접적인 공격보다는 특정 네트워크 터널링(GENEVE 등) 환경에서 커널의 보안 검사 메커니즘을 트리거하여 시스템 경고를 유발함
🛡️ 대응 방법
해당 취약점이 수정된 최신 버전의 Linux 커널로 업데이트하십시오.
🔧 검증 코드
출력된 커널 버전이 해당 패치가 적용된 최신 릴리스 버전인지 확인하십시오.