[PATCH 8/9] smb: client: fix domainauto remount by syncing domainname from session
From: rajasimandalos
Date: Thu Apr 09 2026 - 06:06:03 EST
From: Rajasi Mandal <rajasimandal@xxxxxxxxxxxxx>
When domainauto is used at mount time, ctx->domainname stays NULL
while the server negotiates the actual domain into ses->domainName.
cifs_show_options() reads ses->domainName and outputs domain=X in
/proc/mounts. On remount, libmount re-feeds domain=X, but the
verify check compares against old ctx->domainname (NULL) and rejects
the remount with "can not change domainname during remount".
Steps to reproduce:
1. Mount with domainauto (no explicit domain= option):
mount -t cifs //server/share /mnt \
-o username=u,password=p,domainauto
At this point ctx->domainname is NULL, but the server populates
ses->domainName (e.g. "CORP") during session setup.
2. Bare remount (or any remount):
mount -o remount /mnt
libmount reads /proc/mounts, sees domain=CORP (output by
cifs_show_options() from ses->domainName), and feeds it back
to the kernel. The kernel parses domain=CORP into
new_ctx->domainname="CORP", but old ctx->domainname is still
NULL. smb3_verify_reconfigure_ctx() sees the mismatch and
rejects the remount.
This affects any server that populates ses->domainName during session
setup (Active Directory domain controllers, Azure Files) when the
admin uses domainauto instead of an explicit domain= option.
Fix this by syncing ctx->domainname from ses->domainName in
smb3_sync_ctx_from_negotiated() before the verify check runs.
Signed-off-by: Rajasi Mandal <rajasimandal@xxxxxxxxxxxxx>
---
fs/smb/client/fs_context.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 2be72733ef2e..d804e5da578e 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1232,6 +1232,9 @@ static void smb3_sync_ctx_from_negotiated(struct cifs_sb_info *cifs_sb)
*/
ctx->ops = server->ops;
ctx->vals = server->vals;
+ /* /proc/mounts shows domain= from ses->domainName */
+ if (tcon->ses->domainName && !ctx->domainname)
+ ctx->domainname = kstrdup(tcon->ses->domainName, GFP_KERNEL);
}
/*
--
2.43.0