🇰🇷 한글 설명
Linux 커널 CIFS 클라이언트의 CIFSSMBSetEA() 함수는 확장 속성 값의 길이를 SMB 요청 버퍼 크기와 비교하지 않고 복사하여 힙 버퍼 오버플로우가 발생할 수 있습니다. 패치는 요청 조립 후 복사 이전에 길이 검증을 수행하고 바이트 카운터를 확장하여 정수 오버플로우를 방지합니다.
💡 쉬운 설명
Linux 커널이 SMB 네트워크 공유에 파일 속성을 쓸 때, 데이터 크기를 제대로 확인하지 않아 메모리 영역을 넘어서 쓸 수 있습니다. 이 결함으로 시스템이 비정상 종료되거나 악용될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
smb: client: reject SetEA requests that do not fit the request buffer
CIFSSMBSetEA() copies the caller's extended attribute value into the
SMB request buffer without checking that it fits. The requirement is
stated in the source but was never implemented:
/*BB add length check to see if it would fit in
negotiated SMB buffer size BB */
/* if (ea_value_len > buffer_size - 512 (enough for header)) */
if (ea_value_len)
memcpy(parm_data->list.name + name_len + 1,
ea_value, ea_value_len);
The only bound applied on the way in is in cifs_xattr_set():
#define MAX_EA_VALUE_SIZE CIFSMaxBufSize
...
if (size > MAX_EA_VALUE_SIZE)
CIFSMaxBufSize is the full payload capacity of the buffer, so a value
of exactly that size leaves no room for the SMB header, the TRANS2
parameter block, the fealist header and the EA name that are written
ahead of it in the same object.
SendReceive() already enforces the correct limit on this very length:
if (in_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE)
but it is called after the copy has taken place. An unprivileged
setxattr(2) on an SMB1 mount with a 250-byte name and a 16384-byte
value writes 16384 bytes starting 345 bytes into a 16588-byte
cifs_request object, ending 141 bytes past it:
BUG: KASAN: slab-out-of-bounds in CIFSSMBSetEA+0xabc/0xde0
Write of size 16384 at addr ffff888003aa0159 by task init/68
__asan_memcpy+0x3c/0x60
CIFSSMBSetEA+0xabc/0xde0
cifs_xattr_set+0xd3a/0xff0
__vfs_setxattr+0x13e/0x1a0
The buggy address is located 345 bytes inside of
allocated 16588-byte region
Apply SendReceive()'s limit to the assembled request before the copy
rather than after it, and widen the byte counters so the sum cannot
wrap before it is tested.
byte_count is also tested against U16_MAX, because it is stored in the
16-bit pSMB->ByteCount. That becomes reachable when CIFSMaxBufSize is
raised at module load, where it may be set as high as 1024*127: with a
5-byte EA name and a 65521-byte value, count is exactly U16_MAX while
byte_count is 65556, and cpu_to_le16() would truncate it to 20 and
transmit a frame whose ByteCount does not match its length. Testing
byte_count covers count as well, since byte_count is the larger of the
two and count's only 16-bit consumer is written after this point.
check_add_overflow() is evaluated first so that total_len is assigned
before it is reported.
📍 영향받는 시스템
SMB1(CIFS) 마운트를 사용하는 Linux 커널 (수정 이전 버전)
⚔️ 공격 벡터
SMB1 마운트된 경로에서 권한이 없는 사용자가 긴 이름과 큰 값을 가진 setxattr(2) 호출로 커널 힙 영역을 초과 기록
🛡️ 대응 방법
배포판 제공 최신 커널로 업데이트하거나 해당 패치가 포함된 커널을 적용하고 재부팅; 불필요하면 cifs 모듈 또는 SMB1 사용을 비활성화
🔧 검증 코드
커널 버전이 패치된 배포판 빌드 이상인지 배포사 보안 공지와 대조하고, cifs 모듈이 로드되지 않았다면 이 취약점에 노출되지 않음을 의미합니다.
uname -r && (lsmod | grep -w cifs || echo 'cifs module not loaded')