summaryrefslogtreecommitdiff
path: root/fs/smb
diff options
context:
space:
mode:
authorPaulo Alcantara <pc@manguebit.org>2026-10-12 01:52:46 -0300
committerPaulo Alcantara <pc@manguebit.org>2026-10-13 00:52:25 -0300
commitf13208f26c052d06a10c53eda4c78c930f2b9c47 (patch)
tree813f270beb6af368a35b2122dfa01c96618d20a1 /fs/smb
parentb012ffcd45b0c5bb9eeb57ec1e7e2a71d3f36e06 (diff)
smb: client: allocate struct sess_data on the stack
CIFS_SessSetup() kzalloc()s struct sess_data only to run a synchronous state machine and free it before returning; the object never escapes the function. At 96 bytes it fits comfortably on the stack even under CONFIG_FRAME_WARN=1024, so drop the allocation and its failure path. memzero_explicit() preserves the kfree_sensitive() scrubbing. Signed-off-by: Paulo Alcantara <pc@manguebit.org> Reviewed-by: David Howells <dhowells@redhat.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com> Cc: Shyam Prasad N <sprasad@microsoft.com> Cc: Tom Talpey <tom@talpey.com> Cc: Bharath SM <bharathsm@microsoft.com>
Diffstat (limited to 'fs/smb')
-rw-r--r--fs/smb/client/smb1session.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/fs/smb/client/smb1session.c b/fs/smb/client/smb1session.c
index c45d3254dfac..5f469b4d70f7 100644
--- a/fs/smb/client/smb1session.c
+++ b/fs/smb/client/smb1session.c
@@ -949,34 +949,31 @@ static int select_sec(struct sess_data *sess_data)
int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
struct TCP_Server_Info *server)
{
+ struct sess_data sess_data;
int rc = 0;
- struct sess_data *sess_data;
if (ses == NULL) {
WARN(1, "%s: ses == NULL!", __func__);
return -EINVAL;
}
- sess_data = kzalloc_obj(struct sess_data);
- if (!sess_data)
- return -ENOMEM;
+ sess_data = (struct sess_data) {
+ .xid = xid,
+ .ses = ses,
+ .server = server,
+ .buf0_type = CIFS_NO_BUFFER,
+ };
- sess_data->xid = xid;
- sess_data->ses = ses;
- sess_data->server = server;
- sess_data->buf0_type = CIFS_NO_BUFFER;
-
- rc = select_sec(sess_data);
+ rc = select_sec(&sess_data);
if (rc)
goto out;
- while (sess_data->func)
- sess_data->func(sess_data);
+ while (sess_data.func)
+ sess_data.func(&sess_data);
- /* Store result before we free sess_data */
- rc = sess_data->result;
+ rc = sess_data.result;
out:
- kfree_sensitive(sess_data);
+ memzero_explicit(&sess_data, sizeof(sess_data));
return rc;
}