diff options
| author | Paulo Alcantara <pc@manguebit.org> | 2026-10-12 01:53:14 -0300 |
|---|---|---|
| committer | Paulo Alcantara <pc@manguebit.org> | 2026-10-13 00:52:25 -0300 |
| commit | cafbf020e437365beaeacc682fecd50450dff669 (patch) | |
| tree | 85ae525646158f36ea71fa55e0bca637b33f2653 | |
| parent | f13208f26c052d06a10c53eda4c78c930f2b9c47 (diff) | |
| download | linux-cafbf020e437365beaeacc682fecd50450dff669.tar.gz linux-cafbf020e437365beaeacc682fecd50450dff669.zip | |
smb: client: allocate struct SMB2_sess_data on the stack
SMB2_sess_setup() kzalloc()s struct SMB2_sess_data only to run a
synchronous state machine and free it before returning; the object never
escapes the function. At 88 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>
| -rw-r--r-- | fs/smb/client/smb2pdu.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index f10feec98b38..b140ec0a71a8 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -2004,8 +2004,8 @@ SMB2_select_sec(struct SMB2_sess_data *sess_data) int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, struct TCP_Server_Info *server) { + struct SMB2_sess_data sess_data; int rc = 0; - struct SMB2_sess_data *sess_data; cifs_dbg(FYI, "Session Setup\n"); @@ -2014,17 +2014,15 @@ int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, return smb_EIO(smb_eio_trace_null_pointers); } - sess_data = kzalloc_obj(struct SMB2_sess_data); - if (!sess_data) - return -ENOMEM; - - sess_data->xid = xid; - sess_data->ses = ses; - sess_data->server = server; - sess_data->buf0_type = CIFS_NO_BUFFER; - sess_data->previous_session = ses->Suid; + sess_data = (struct SMB2_sess_data) { + .xid = xid, + .ses = ses, + .server = server, + .buf0_type = CIFS_NO_BUFFER, + .previous_session = ses->Suid, + }; - rc = SMB2_select_sec(sess_data); + rc = SMB2_select_sec(&sess_data); if (rc) goto out; @@ -2034,14 +2032,14 @@ int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, memcpy(ses->preauth_sha_hash, server->preauth_sha_hash, SMB2_PREAUTH_HASH_SIZE); - while (sess_data->func) - sess_data->func(sess_data); + while (sess_data.func) + sess_data.func(&sess_data); if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign)) cifs_server_dbg(VFS, "signing requested but authenticated as guest\n"); - rc = sess_data->result; + rc = sess_data.result; out: - kfree_sensitive(sess_data); + memzero_explicit(&sess_data, sizeof(sess_data)); return rc; } |
