2023-07-17 10:03:12

by Minjie Du

[permalink] [raw]
Subject: [PATCH v1] scsi: iscsi: use kfree_sensitive() in iscsi_session_free()

session might contain private part of the password, so better use
kfree_sensitive() to free it.
In iscsi_session_free() use kfree_sensitive() to free session->password.

Signed-off-by: Minjie Du <[email protected]>
---
drivers/scsi/libiscsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 0fda8905e..2f273229c 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -3132,7 +3132,7 @@ void iscsi_session_free(struct iscsi_cls_session *cls_session)
struct module *owner = cls_session->transport->owner;

iscsi_pool_free(&session->cmdpool);
- kfree(session->password);
+ kfree_sensitive(session->password);
kfree(session->password_in);
kfree(session->username);
kfree(session->username_in);
--
2.39.0



2023-07-17 18:03:53

by Lee Duncan

[permalink] [raw]
Subject: Re: [PATCH v1] scsi: iscsi: use kfree_sensitive() in iscsi_session_free()

On 7/17/23 02:26, Minjie Du wrote:
> session might contain private part of the password, so better use
> kfree_sensitive() to free it.
> In iscsi_session_free() use kfree_sensitive() to free session->password.
>
> Signed-off-by: Minjie Du <[email protected]>
> ---
> drivers/scsi/libiscsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 0fda8905e..2f273229c 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -3132,7 +3132,7 @@ void iscsi_session_free(struct iscsi_cls_session *cls_session)
> struct module *owner = cls_session->transport->owner;
>
> iscsi_pool_free(&session->cmdpool);
> - kfree(session->password);
> + kfree_sensitive(session->password);
> kfree(session->password_in);
> kfree(session->username);
> kfree(session->username_in);

Reviewed-by: Lee Duncan <[email protected]>

2023-07-17 19:46:46

by Mike Christie

[permalink] [raw]
Subject: Re: [PATCH v1] scsi: iscsi: use kfree_sensitive() in iscsi_session_free()

On 7/17/23 4:26 AM, Minjie Du wrote:
> session might contain private part of the password, so better use
> kfree_sensitive() to free it.
> In iscsi_session_free() use kfree_sensitive() to free session->password.
>
> Signed-off-by: Minjie Du <[email protected]>
> ---
> drivers/scsi/libiscsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 0fda8905e..2f273229c 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -3132,7 +3132,7 @@ void iscsi_session_free(struct iscsi_cls_session *cls_session)
> struct module *owner = cls_session->transport->owner;
>
> iscsi_pool_free(&session->cmdpool);
> - kfree(session->password);
> + kfree_sensitive(session->password);
> kfree(session->password_in);

You then also want kfree_sensitive for password_in.

I would also use it for the usernames then too.

> kfree(session->username);
> kfree(session->username_in);