From: Haoxiang Li <make24@iscas.ac.cn>
To: sfrench@samba.org, pc@manguebit.com, ronniesahlberg@gmail.com,
sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, Haoxiang Li <make24@iscas.ac.cn>
Subject: [PATCH] fs: smb: client: Add missing check for kstrdup()
Date: Mon, 1 Jul 2024 14:48:47 +0800 [thread overview]
Message-ID: <20240701064847.84726-1-make24@iscas.ac.cn> (raw)
Add check for kstrdup() in smb3_reconfigure in order to guarantee
the success of allocation.
Fixes: c1eb537bf456 ("cifs: allow changing password during remount")
Signed-off-by: Haoxiang Li <make24@iscas.ac.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 3bbac925d076..8253b615b8ce 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -920,6 +920,8 @@ static int smb3_reconfigure(struct fs_context *fc)
ses->password = kstrdup(ctx->password, GFP_KERNEL);
kfree_sensitive(ses->password2);
ses->password2 = kstrdup(ctx->password2, GFP_KERNEL);
+ if (!ses->password || !ses->password2)
+ return ERR_PTR(rc);
}
STEAL_STRING(cifs_sb, ctx, domainname);
STEAL_STRING(cifs_sb, ctx, nodename);
--
2.25.1
next reply other threads:[~2024-07-01 6:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 6:48 Haoxiang Li [this message]
2024-07-01 13:01 ` [PATCH] fs: smb: client: Add missing check for kstrdup() Markus Elfring
2024-10-22 17:15 ` [PATCH v2] fs_context.c: smb3_reconfigure: Handle kstrdup failures for passwords Henrique Carvalho
2024-10-22 18:21 ` [PATCH v3] smb: client: " Henrique Carvalho
2024-10-22 22:21 ` Steve French
2024-11-04 11:06 ` Markus Elfring
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=20240701064847.84726-1-make24@iscas.ac.cn \
--to=make24@iscas.ac.cn \
--cc=bharathsm@microsoft.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/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