🇰🇷 한글 설명
Linux 커널의 SMB 클라이언트에서 TCP 타이머 관련 잘못된 수정으로 인해 발생한 취약점입니다. 특정 상황에서 TCP 소켓이 FIN_WAIT_1 상태로 영원히 남아 소켓 누수가 발생하거나, 네트워크 네임스페이스 해제 후 타이머가 작동하여 Use-After-Free 취약점을 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터가 네트워크 연결을 끊을 때 필요한 타이머 기능이 제대로 작동하지 않아, 연결 정보가 메모리에 계속 쌓이거나 시스템이 충돌할 수 있는 문제입니다. 잘못된 패치로 인해 오히려 시스템 안정성을 해치는 상황이 발생했습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
Revert "smb: client: fix TCP timers deadlock after rmmod"
This reverts commit e9f2517a3e18a54a3943c098d2226b245d488801.
Commit e9f2517a3e18 ("smb: client: fix TCP timers deadlock after
rmmod") is intended to fix a null-ptr-deref in LOCKDEP, which is
mentioned as CVE-2024-54680, but is actually did not fix anything;
The issue can be reproduced on top of it. [0]
Also, it reverted the change by commit ef7134c7fc48 ("smb: client:
Fix use-after-free of network namespace.") and introduced a real
issue by reviving the kernel TCP socket.
When a reconnect happens for a CIFS connection, the socket state
transitions to FIN_WAIT_1. Then, inet_csk_clear_xmit_timers_sync()
in tcp_close() stops all timers for the socket.
If an incoming FIN packet is lost, the socket will stay at FIN_WAIT_1
forever, and such sockets could be leaked up to net.ipv4.tcp_max_orphans.
Usually, FIN can be retransmitted by the peer, but if the peer aborts
the connection, the issue comes into reality.
I warned about this privately by pointing out the exact report [1],
but the bogus fix was finally merged.
So, we should not stop the timers to finally kill the connection on
our side in that case, meaning we must not use a kernel socket for
TCP whose sk->sk_net_refcnt is 0.
The kernel socket does not have a reference to its netns to make it
possible to tear down netns without cleaning up every resource in it.
For example, tunnel devices use a UDP socket internally, but we can
destroy netns without removing such devices and let it complete
during exit. Otherwise, netns would be leaked when the last application
died.
However, this is problematic for TCP sockets because TCP has timers to
close the connection gracefully even after the socket is close()d. The
lifetime of the socket and its netns is different from the lifetime of
the underlying connection.
If the socket user does not maintain the netns lifetime, the timer could
be fired after the socket is close()d and its netns is freed up, resulting
in use-after-free.
Actually, we have seen so many similar issues and converted such sockets
to have a reference to netns.
That's why I converted the CIFS client socket to have a reference to
netns (sk->sk_net_refcnt == 1), which is somehow mentioned as out-of-scope
of CIFS and technically wrong in e9f2517a3e18, but **is in-scope and right
fix**.
Regarding the LOCKDEP issue, we can prevent the module unload by
bumping the module refcount when switching the LOCKDDEP key in
sock_lock_init_class_and_name(). [2]
For a while, let's revert the bogus fix.
Note that now we can use sk_net_refcnt_upgrade() for the socket
conversion, but I'll do so later separately to make backport easy.
📍 영향받는 시스템
Linux kernel (SMB client module 사용 환경)
⚔️ 공격 벡터
네트워크 연결 재시도 과정에서 상대방이 연결을 강제로 중단(Abort)할 때 발생
🛡️ 대응 방법
잘못된 패치(e9f2517a3e18)를 되돌리고(Revert), CIFS 클라이언트 소켓이 네트워크 네임스페이스 참조를 유지하도록 수정된 최신 커널로 업데이트하십시오.
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 수정된 최신 버전인지 확인하십시오.