From: ChenXiaoSong <chenxiaosong.chenxiaosong@linux.dev>
To: Zilin Guan <zilin@seu.edu.cn>,
sfrench@samba.org, Steve French <smfrench@gmail.com>
Cc: pc@manguebit.org, ronniesahlberg@gmail.com,
sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] cifs: Fix memory and information leak in smb3_reconfigure()
Date: Thu, 25 Dec 2025 00:23:20 +0800 [thread overview]
Message-ID: <39ca2ff6-c363-47d7-9d4f-fd6f137afc09@linux.dev> (raw)
In-Reply-To: <20251224152142.289149-1-zilin@seu.edu.cn>
Good catch. Looks good to me.
Thanks,
ChenXiaoSong.
On 12/24/25 11:21 PM, Zilin Guan wrote:
> In smb3_reconfigure(), if smb3_sync_session_ctx_passwords() fails, the
> function returns immediately without freeing and erasing the newly
> allocated new_password and new_password2. This causes both a memory leak
> and a potential information leak.
>
> Fix this by calling kfree_sensitive() on both password buffers before
> returning in this error case.
>
> Fixes: 0f0e357902957 ("cifs: during remount, make sure passwords are in sync")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
> fs/smb/client/fs_context.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index c2de97e4ad59..d4291d3a9a48 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1139,6 +1139,8 @@ static int smb3_reconfigure(struct fs_context *fc)
> rc = smb3_sync_session_ctx_passwords(cifs_sb, ses);
> if (rc) {
> mutex_unlock(&ses->session_mutex);
> + kfree_sensitive(new_password);
> + kfree_sensitive(new_password2);
> return rc;
> }
>
prev parent reply other threads:[~2025-12-24 16:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 15:21 Zilin Guan
2025-12-24 16:23 ` ChenXiaoSong [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=39ca2ff6-c363-47d7-9d4f-fd6f137afc09@linux.dev \
--to=chenxiaosong.chenxiaosong@linux.dev \
--cc=bharathsm@microsoft.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
--cc=zilin@seu.edu.cn \
/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
all inboxes | Powered by JetHome®