Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] ksmbd: enable TCP keepalive for accepted connections
@ 2026-08-20 13:54 Namjae Jeon
  2026-08-20 13:54 ` [PATCH] ksmbd: keep TCP timers alive for kernel sockets Namjae Jeon
  2026-08-20 13:54 ` [PATCH 4/6] smb: server: remove unused DES crypto header Namjae Jeon
  0 siblings, 2 replies; 3+ messages in thread
From: Namjae Jeon @ 2026-08-20 13:54 UTC (permalink / raw)
  To: linux-cifs
  Cc: senozhatsky, tom, atteh.mailbox, chenxiaosong, chenxiaosong,
	Namjae Jeon

A client that disappears without sending a FIN or RST can leave its
ksmbd connection in ESTABLISHED indefinitely. ksmbd sets a socket
receive timeout, but the connection receive loop retries timeout errors
without a limit, so the connection remains in conn_list and consumes the
per-IP connection quota.

Enable SO_KEEPALIVE on accepted TCP sockets so the TCP stack can detect a
silent peer failure. The keepalive idle time, interval, and probe count
remain controlled by the existing TCP sysctl settings.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/smb/server/transport_tcp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c
index 0ae5f145a332..921e4e86d01c 100644
--- a/fs/smb/server/transport_tcp.c
+++ b/fs/smb/server/transport_tcp.c
@@ -292,6 +292,12 @@ static int ksmbd_kthread_fn(void *p)
 		ksmbd_debug(CONN, "connect success: accepted new connection\n");
 		client_sk->sk->sk_rcvtimeo = KSMBD_TCP_RECV_TIMEOUT;
 		client_sk->sk->sk_sndtimeo = KSMBD_TCP_SEND_TIMEOUT;
+		/*
+		 * Detect peers that disappear without sending a FIN or RST.
+		 * Otherwise the connection handler can retry receive timeouts
+		 * indefinitely and keep the connection in conn_list.
+		 */
+		sock_set_keepalive(client_sk->sk);
 
 		ksmbd_tcp_new_connection(client_sk);
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] ksmbd: keep TCP timers alive for kernel sockets
  2026-08-20 13:54 [PATCH] ksmbd: enable TCP keepalive for accepted connections Namjae Jeon
@ 2026-08-20 13:54 ` Namjae Jeon
  2026-08-20 13:54 ` [PATCH 4/6] smb: server: remove unused DES crypto header Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2026-08-20 13:54 UTC (permalink / raw)
  To: linux-cifs
  Cc: senozhatsky, tom, atteh.mailbox, chenxiaosong, chenxiaosong,
	Namjae Jeon

ksmbd creates its listening socket with sock_create_kern(). Kernel
sockets do not hold a network namespace reference by default. Accepted
sockets inherit this state.

When an accepted socket is released, tcp_close() clears its pending TCP
timers for a kernel socket after the socket enters an orphaned state. If
the peer is unreachable while ksmbd sends a FIN, this can leave a
FIN-WAIT-1 orphan without a retransmission timer.

Upgrade the listening socket's network namespace reference before
kernel_listen(). Accepted sockets inherit the reference, so the TCP
stack can keep the retransmission timer active and apply its normal
orphan retry policy.

Preserve the existing graceful shutdown behavior.

Link: https://github.com/openwrt/openwrt/issues/24744
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/smb/server/transport_tcp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c
index 921e4e86d01c..832e93084605 100644
--- a/fs/smb/server/transport_tcp.c
+++ b/fs/smb/server/transport_tcp.c
@@ -523,6 +523,12 @@ static int create_socket(struct interface *iface)
 		goto out_error;
 	}
 
+	/*
+	 * Accepted sockets inherit the listener's net reference. Keep TCP
+	 * timers alive after a kernel socket is released.
+	 */
+	sk_net_refcnt_upgrade(ksmbd_socket->sk);
+
 	ret = kernel_listen(ksmbd_socket, KSMBD_SOCKET_BACKLOG);
 	if (ret) {
 		pr_err("Port listen() error: %d\n", ret);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 4/6] smb: server: remove unused DES crypto header
  2026-08-20 13:54 [PATCH] ksmbd: enable TCP keepalive for accepted connections Namjae Jeon
  2026-08-20 13:54 ` [PATCH] ksmbd: keep TCP timers alive for kernel sockets Namjae Jeon
@ 2026-08-20 13:54 ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2026-08-20 13:54 UTC (permalink / raw)
  To: linux-cifs
  Cc: senozhatsky, tom, atteh.mailbox, chenxiaosong, chenxiaosong,
	Namjae Jeon

The DES crypto header is no longer used after the removal of NTLMv1
authentication. Remove it now that the server no longer selects
CRYPTO_LIB_DES.

Fixes: ce812992f239 ("ksmbd: remove NTLMv1 authentication")
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/smb/server/auth.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/smb/server/auth.c b/fs/smb/server/auth.c
index 9f3151a9f379..5ec43e32de3e 100644
--- a/fs/smb/server/auth.c
+++ b/fs/smb/server/auth.c
@@ -24,7 +24,6 @@
 
 #include <linux/fips.h>
 #include <crypto/arc4.h>
-#include <crypto/des.h>
 
 #include "server.h"
 #include "smb_common.h"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-20 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 13:54 [PATCH] ksmbd: enable TCP keepalive for accepted connections Namjae Jeon
2026-08-20 13:54 ` [PATCH] ksmbd: keep TCP timers alive for kernel sockets Namjae Jeon
2026-08-20 13:54 ` [PATCH 4/6] smb: server: remove unused DES crypto header Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox