smb: client: Better exception handling for SMB3 hash allocations
Subsystems (3)
cover smb: client: Better exception handling for SMB3 hash allocations
From: Markus Elfring <[email protected]>
Date: Fri, 10 Oct 2025 08:40:08 +0200
Refine a few implementation details for further development considerations.
Markus Elfring (3):
Return directly after a failed cifs_alloc_hash()
in smb3_crypto_shash_allocate()
Improve resource release
in smb311_crypto_shash_allocate()
Omit a variable initialisation
in smb311_crypto_shash_allocate()
fs/smb/client/smb2transport.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/3 smb: client: Return directly after a failed cifs_alloc_hash() in smb3_crypto_shash_allocate()
From: Markus Elfring <[email protected]>
Date: Thu, 9 Oct 2025 18:44:53 +0200
Return directly after a call of the function “cifs_alloc_hash” failed at the beginning.
--- fs/smb/client/smb2transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2transport.c +1 -1
@@ -34,7 +34,7 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server) rc =cifs_alloc_hash ("hmac(sha256)" , &p->hmacsha256);if (rc) - goto err; +return rc; rc =cifs_alloc_hash ("cmac(aes)" , &p->aes_cmac);if (rc)
Signature · 1 line
2.51.0
PATCH 2/3 smb: client: Improve resource release in smb311_crypto_shash_allocate()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 9 Oct 2025 19:00:11 +0200
Adjust jump targets so that cifs_free_hash() functions will be called in a recommended order at the end of this function implementation.
--- fs/smb/client/smb2transport.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/smb/client/smb2transport.c +4 -3
@@ -58,16 +58,17 @@ smb311_crypto_shash_allocate(struct TCP_Server_Info *server) rc =cifs_alloc_hash ("cmac(aes)" , &p->aes_cmac);if (rc) - goto err; + goto free_hmacsha256; rc =cifs_alloc_hash ("sha512" , &p->sha512);if (rc) - goto err; + goto free_aes_cmac;return 0 ; -err: +free_aes_cmac:cifs_free_hash (&p->aes_cmac); +free_hmacsha256:cifs_free_hash (&p->hmacsha256);return rc; }
Signature · 1 line
2.51.0
PATCH 3/3 smb: client: Omit a variable initialisation in smb311_crypto_shash_allocate()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 10 Oct 2025 08:05:21 +0200
Subject: [PATCH 3/3] smb: client: Omit a variable initialisation in smb311_crypto_shash_allocate()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The local variable “rc” is immediately reassigned. Thus omit the explicit initialisation at the beginning.
--- fs/smb/client/smb2transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2transport.c +1 -1
@@ -50,7 +50,7 @@ int smb311_crypto_shash_allocate(struct TCP_Server_Info *server) {struct cifs_secmech *p = &server->secmech; -int rc =0 ; +int rc; rc =cifs_alloc_hash ("hmac(sha256)" , &p->hmacsha256);if (rc)
Signature · 1 line
2.51.0
Steve French
AppliedRe: [PATCH 3/3] smb: client: Omit a variable initialisation in smb311_crypto_shash_allocate()
merged into cifs-2.6.git for-next
Quoted 34 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 10 Oct 2025 08:05:21 +0200
Subject: [PATCH 3/3] smb: client: Omit a variable initialisation insmb311_crypto_shash_allocate()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe local variable “rc” is immediately reassigned. Thus omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- fs/smb/client/smb2transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2transport.c +1
-2@@ -50,7 +50,7 @@ int smb311_crypto_shash_allocate(struct TCP_Server_Info *server) {struct cifs_secmech *p = &server->secmech; -int rc =0 ; +int rc; rc =cifs_alloc_hash ("hmac(sha256)" , &p->hmacsha256);if (rc) --2.51.0
Signature · 3 lines
Thanks, Steve
Re: [PATCH 3/3] smb: client: Omit a variable initialisation in smb311_crypto_shash_allocate()
Removed from cifs-2.6.git for-next, as it conflicts with Eric's recent patch series ("smb: client: More crypto library conversions").
Obviously one of the problems of minor cleanup patches, is they can cause noise like this
Quoted 44 lines · Steve French
merged into cifs-2.6.git for-next
Quoted 30 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 10 Oct 2025 08:05:21 +0200
Subject: [PATCH 3/3] smb: client: Omit a variable initialisation insmb311_crypto_shash_allocate()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe local variable “rc” is immediately reassigned. Thus omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- fs/smb/client/smb2transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2transport.c +1
-2@@ -50,7 +50,7 @@ int smb311_crypto_shash_allocate(struct TCP_Server_Info *server) {struct cifs_secmech *p = &server->secmech; -int rc =0 ; +int rc; rc =cifs_alloc_hash ("hmac(sha256)" , &p->hmacsha256);if (rc) --Quoted 4 lines
2.51.0
--
Thanks,Steve
Signature · 3 lines
Thanks, Steve
Quoted 1 line
Refine a few implementation details for further development considerations.
Software components are evolving further somehow.
See also:
[PATCH 7/8] smb: client: Remove obsolete crypto_shash allocations
https://lore.kernel.org/linux-cifs/[email protected]/
https://lkml.org/lkml/2025/10/11/443
Regards,
Markus