Skip to contentSkip to conversation

FAILED: patch "[PATCH] ksmbd: ignore network devices of other namespaces" failed to apply to 5.15-stable tree

PATCH New [email protected] 2 participants 2 messages Nov 3

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 1f5ce2b8b9164b3fcb93a18fe1e7b451c2fc6eea
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110346-accuracy-product-ad13@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 1f5ce2b8b9164b3fcb93a18fe1e7b451c2fc6eea Mon Sep 17 00:00:00 2001
From: Jan Koester <[email protected]>
Date: Mon, 26 Oct 2026 10:25:37 +0100
Subject: [PATCH] ksmbd: ignore network devices of other namespaces

With no interface list configured, ksmbd binds every interface that comes up. ksmbd_netdev_event() does not look at the device's namespace, and create_socket() opens the listener in the namespace of the task raising NETDEV_UP. A container with its own address on a bridge brings up its interface and finds port 445 in its namespace already taken by ksmbd, so an SMB server running inside the container fails with "Address already in use".

Interfaces are also matched by name only, so a container's eth0 going down would stop the listener on the host's eth0.

Only handle netdev events for devices in init_net.

Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
fs/smb/server/transport_tcp.c +9 -0
index 937d321fa364..c51b2f7d8b27 100644
@@ -858,6 +858,15 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
 	struct interface *iface;
 	int ret;
 
+	/*
+	 * ksmbd serves the initial namespace only. create_socket() listens in
+	 * the namespace of the task raising the event, so a container bringing
+	 * up its own interface would get a listener on its port 445, and the
+	 * name-only interface lookup would let its interfaces stop ours.
+	 */
+	if (!net_eq(dev_net(netdev), &init_net))
+		return NOTIFY_DONE;
+
 	switch (event) {
 	case NETDEV_UP:
 		if (netif_is_bridge_port(netdev))
maintainer
#1 lore raw

PATCH 1/1 ksmbd: ignore network devices of other namespaces

From: Jan Koester <[email protected]>

[ Upstream commit 1f5ce2b8b9164b3fcb93a18fe1e7b451c2fc6eea ]

With no interface list configured, ksmbd binds every interface that comes up. ksmbd_netdev_event() does not look at the device's namespace, and create_socket() opens the listener in the namespace of the task raising NETDEV_UP. A container with its own address on a bridge brings up its interface and finds port 445 in its namespace already taken by ksmbd, so an SMB server running inside the container fails with "Address already in use".

Interfaces are also matched by name only, so a container's eth0 going down would stop the listener on the host's eth0.

Only handle netdev events for devices in init_net.

Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
[ sashal: Adapted the patch to the older ksmbd implementation location. ]
---
 fs/ksmbd/transport_tcp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ksmbd/transport_tcp.c +9 -0
index c0a038666ec34..ac34fc15b0c13 100644
@@ -514,6 +514,15 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
 	struct interface *iface;
 	int ret, found = 0;
 
+	/*
+	 * ksmbd serves the initial namespace only. create_socket() listens in
+	 * the namespace of the task raising the event, so a container bringing
+	 * up its own interface would get a listener on its port 445, and the
+	 * name-only interface lookup would let its interfaces stop ours.
+	 */
+	if (!net_eq(dev_net(netdev), &init_net))
+		return NOTIFY_DONE;
+
 	switch (event) {
 	case NETDEV_UP:
 		if (netif_is_bridge_port(netdev))
Signature · 1 line
2.53.0