From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Jan Koester <j.koester@act-marketing.de>,
Namjae Jeon <linkinjeon@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y] ksmbd: ignore network devices of other namespaces
Date: Tue, 3 Nov 2026 11:39:38 -0500 [thread overview]
Message-ID: <20261103163910.284897-1-sashal@kernel.org> (raw)
In-Reply-To: <2026110346-accuracy-product-ad13@gregkh>
From: Jan Koester <j.koester@act-marketing.de>
[ 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")
Cc: stable@vger.kernel.org
Signed-off-by: Jan Koester <j.koester@act-marketing.de>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: Adapted the patch to the older ksmbd implementation location. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ksmbd/transport_tcp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/ksmbd/transport_tcp.c b/fs/ksmbd/transport_tcp.c
index c0a038666ec34..ac34fc15b0c13 100644
--- a/fs/ksmbd/transport_tcp.c
+++ b/fs/ksmbd/transport_tcp.c
@@ -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))
--
2.53.0
prev parent reply other threads:[~2026-11-03 16:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:17 FAILED: patch "[PATCH] ksmbd: ignore network devices of other namespaces" failed to apply to 5.15-stable tree gregkh
2026-11-03 16:39 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103163910.284897-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=j.koester@act-marketing.de \
--cc=linkinjeon@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox