🇰🇷 한글 설명
Linux 커널의 SMB 클라이언트에서 서버 측 복사 및 클론 작업 시 목적지 페이지 캐시를 적절히 비우거나 무효화하지 못하는 취약점입니다. 이로 인해 비동기 쓰기 작업이 서버 측 복사 완료 후 실행되어 파일 데이터가 오염될 수 있습니다.
💡 쉬운 설명
파일을 복사하거나 수정할 때 컴퓨터가 이전 데이터를 완전히 지우지 않고 새 데이터를 덮어쓰는 과정에서 오류가 발생합니다. 이로 인해 저장된 파일의 내용이 깨지거나 잘못된 데이터로 바뀔 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
smb: client: drain and invalidate before server-side copy/clone
cifs_file_copychunk_range() and the clone (FICLONE) path of
cifs_remap_file_range() do not serialise the destination page cache
against the server-side copy the way the other server-side range
operations (smb3_zero_range(), smb3_punch_hole(), smb3_collapse_range()
and smb3_insert_range()) do.
cifs_file_copychunk_range() invalidates the destination range with
filemap_invalidate_inode(), which takes and drops the mapping's
invalidate_lock internally, so the lock is no longer held when the
copychunk ioctl is issued. It also never drains in-flight netfs I/O on
the target. The clone path never takes the invalidate_lock at all (only
i_rwsem), uses a bare truncate_inode_pages_range() and likewise does not
drain outstanding I/O.
As a result an asynchronous destination writeback can complete after the
server-side copy/clone has run and reinstate stale data over the region
just written by the server, corrupting the file. This is the same class
of corruption as commit d7d2adcd022b ("smb/client: flush dirty data
before punching a hole") and has been seen randomly in generic/363
against Windows Server.
Fix both paths to follow the established ordering: hold the target
mapping's invalidate_lock across the flush and invalidation of the
destination and the server ioctl, and call netfs_wait_for_outstanding_io()
on the target to drain in-flight writes before the ioctl is issued. Only
the target inode's invalidate_lock is required, as the source is merely
flushed and not invalidated; i_rwsem (already held via
lock_two_nondirectories()) is acquired before the invalidate_lock,
matching the VFS lock ordering. Since filemap_invalidate_inode() takes
that same lock internally, replace it with its own unmap/flush/invalidate
steps instead of calling it, and return early on a zero-length copy to
avoid a range underflow.
📍 영향받는 시스템
Linux kernel (SMB client component)
⚔️ 공격 벡터
서버 측 복사/클론(FICLONE) 작업 중 비동기 쓰기 발생을 유도하여 파일 데이터 오염 유발
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 invalidate_lock 및 netfs_wait_for_outstanding_io() 로직을 적용해야 합니다.
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 수정된 패치 버전 이상인지 확인합니다.