* [PATCH] smb: use crypto_shash_digest() in symlink_hash()
@ 2023-10-29 5:03 Eric Biggers
2023-10-30 1:10 ` Steve French
2023-10-31 14:57 ` Paulo Alcantara
0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2023-10-29 5:03 UTC (permalink / raw)
To: Steve French, linux-cifs; +Cc: linux-crypto
From: Eric Biggers <ebiggers@google.com>
Simplify symlink_hash() by using crypto_shash_digest() instead of an
init+update+final sequence. This should also improve performance.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/smb/client/link.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c
index c66be4904e1f..a1da50e66fbb 100644
--- a/fs/smb/client/link.c
+++ b/fs/smb/client/link.c
@@ -35,37 +35,25 @@
#define CIFS_MF_SYMLINK_MD5_ARGS(md5_hash) md5_hash
static int
symlink_hash(unsigned int link_len, const char *link_str, u8 *md5_hash)
{
int rc;
struct shash_desc *md5 = NULL;
rc = cifs_alloc_hash("md5", &md5);
if (rc)
- goto symlink_hash_err;
+ return rc;
- rc = crypto_shash_init(md5);
- if (rc) {
- cifs_dbg(VFS, "%s: Could not init md5 shash\n", __func__);
- goto symlink_hash_err;
- }
- rc = crypto_shash_update(md5, link_str, link_len);
- if (rc) {
- cifs_dbg(VFS, "%s: Could not update with link_str\n", __func__);
- goto symlink_hash_err;
- }
- rc = crypto_shash_final(md5, md5_hash);
+ rc = crypto_shash_digest(md5, link_str, link_len, md5_hash);
if (rc)
cifs_dbg(VFS, "%s: Could not generate md5 hash\n", __func__);
-
-symlink_hash_err:
cifs_free_hash(&md5);
return rc;
}
static int
parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len,
char **_link_str)
{
int rc;
unsigned int link_len;
base-commit: 2af9b20dbb39f6ebf9b9b6c090271594627d818e
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] smb: use crypto_shash_digest() in symlink_hash()
2023-10-29 5:03 [PATCH] smb: use crypto_shash_digest() in symlink_hash() Eric Biggers
@ 2023-10-30 1:10 ` Steve French
2023-10-31 14:57 ` Paulo Alcantara
1 sibling, 0 replies; 3+ messages in thread
From: Steve French @ 2023-10-30 1:10 UTC (permalink / raw)
To: Eric Biggers; +Cc: Steve French, linux-cifs, linux-crypto
tentatively merged into cifs-2.6.git for-next pending additional testing
On Sun, Oct 29, 2023 at 12:03 AM Eric Biggers <ebiggers@kernel.org> wrote:
>
> From: Eric Biggers <ebiggers@google.com>
>
> Simplify symlink_hash() by using crypto_shash_digest() instead of an
> init+update+final sequence. This should also improve performance.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> fs/smb/client/link.c | 16 ++--------------
> 1 file changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c
> index c66be4904e1f..a1da50e66fbb 100644
> --- a/fs/smb/client/link.c
> +++ b/fs/smb/client/link.c
> @@ -35,37 +35,25 @@
> #define CIFS_MF_SYMLINK_MD5_ARGS(md5_hash) md5_hash
>
> static int
> symlink_hash(unsigned int link_len, const char *link_str, u8 *md5_hash)
> {
> int rc;
> struct shash_desc *md5 = NULL;
>
> rc = cifs_alloc_hash("md5", &md5);
> if (rc)
> - goto symlink_hash_err;
> + return rc;
>
> - rc = crypto_shash_init(md5);
> - if (rc) {
> - cifs_dbg(VFS, "%s: Could not init md5 shash\n", __func__);
> - goto symlink_hash_err;
> - }
> - rc = crypto_shash_update(md5, link_str, link_len);
> - if (rc) {
> - cifs_dbg(VFS, "%s: Could not update with link_str\n", __func__);
> - goto symlink_hash_err;
> - }
> - rc = crypto_shash_final(md5, md5_hash);
> + rc = crypto_shash_digest(md5, link_str, link_len, md5_hash);
> if (rc)
> cifs_dbg(VFS, "%s: Could not generate md5 hash\n", __func__);
> -
> -symlink_hash_err:
> cifs_free_hash(&md5);
> return rc;
> }
>
> static int
> parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len,
> char **_link_str)
> {
> int rc;
> unsigned int link_len;
>
> base-commit: 2af9b20dbb39f6ebf9b9b6c090271594627d818e
> --
> 2.42.0
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] smb: use crypto_shash_digest() in symlink_hash()
2023-10-29 5:03 [PATCH] smb: use crypto_shash_digest() in symlink_hash() Eric Biggers
2023-10-30 1:10 ` Steve French
@ 2023-10-31 14:57 ` Paulo Alcantara
1 sibling, 0 replies; 3+ messages in thread
From: Paulo Alcantara @ 2023-10-31 14:57 UTC (permalink / raw)
To: Eric Biggers, Steve French, linux-cifs; +Cc: linux-crypto
Eric Biggers <ebiggers@kernel.org> writes:
> From: Eric Biggers <ebiggers@google.com>
>
> Simplify symlink_hash() by using crypto_shash_digest() instead of an
> init+update+final sequence. This should also improve performance.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> fs/smb/client/link.c | 16 ++--------------
> 1 file changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c
> index c66be4904e1f..a1da50e66fbb 100644
> --- a/fs/smb/client/link.c
> +++ b/fs/smb/client/link.c
Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-31 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-29 5:03 [PATCH] smb: use crypto_shash_digest() in symlink_hash() Eric Biggers
2023-10-30 1:10 ` Steve French
2023-10-31 14:57 ` Paulo Alcantara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox