* [PATCH] ksmbd: fix possible memory leak in smb2_lock()
@ 2023-02-01 8:10 Hangyu Hua
2023-02-04 10:10 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: Hangyu Hua @ 2023-02-01 8:10 UTC (permalink / raw)
To: linkinjeon, sfrench, senozhatsky, tom, hyc.lee, lsahlber
Cc: linux-cifs, linux-kernel, Hangyu Hua
argv needs to be free when setup_async_work fails or when the current
process is woken up.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
fs/ksmbd/smb2pdu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index d681f91947d9..5b7668c04f76 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -7050,6 +7050,7 @@ int smb2_lock(struct ksmbd_work *work)
smb2_remove_blocked_lock,
argv);
if (rc) {
+ kfree(argv);
err = -ENOMEM;
goto out;
}
@@ -7061,6 +7062,8 @@ int smb2_lock(struct ksmbd_work *work)
ksmbd_vfs_posix_lock_wait(flock);
+ work->cancel_fn = NULL;
+ kfree(argv);
if (work->state != KSMBD_WORK_ACTIVE) {
list_del(&smb_lock->llist);
spin_lock(&work->conn->llist_lock);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ksmbd: fix possible memory leak in smb2_lock()
2023-02-01 8:10 [PATCH] ksmbd: fix possible memory leak in smb2_lock() Hangyu Hua
@ 2023-02-04 10:10 ` Namjae Jeon
2023-02-06 2:33 ` Hangyu Hua
0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2023-02-04 10:10 UTC (permalink / raw)
To: Hangyu Hua
Cc: sfrench, senozhatsky, tom, hyc.lee, lsahlber, linux-cifs, linux-kernel
2023-02-01 17:10 GMT+09:00, Hangyu Hua <hbh25y@gmail.com>:
> argv needs to be free when setup_async_work fails or when the current
> process is woken up.
>
> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
> fs/ksmbd/smb2pdu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index d681f91947d9..5b7668c04f76 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -7050,6 +7050,7 @@ int smb2_lock(struct ksmbd_work *work)
> smb2_remove_blocked_lock,
> argv);
> if (rc) {
> + kfree(argv);
> err = -ENOMEM;
> goto out;
> }
> @@ -7061,6 +7062,8 @@ int smb2_lock(struct ksmbd_work *work)
>
> ksmbd_vfs_posix_lock_wait(flock);
>
> + work->cancel_fn = NULL;
> + kfree(argv);
This change seems to causes a NULL pointer dereference issue in
set_close_state_blocked_works(). It is right to free it and set NULL
after removing entry from list.
> if (work->state != KSMBD_WORK_ACTIVE) {
> list_del(&smb_lock->llist);
> spin_lock(&work->conn->llist_lock);
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ksmbd: fix possible memory leak in smb2_lock()
2023-02-04 10:10 ` Namjae Jeon
@ 2023-02-06 2:33 ` Hangyu Hua
0 siblings, 0 replies; 3+ messages in thread
From: Hangyu Hua @ 2023-02-06 2:33 UTC (permalink / raw)
To: Namjae Jeon
Cc: sfrench, senozhatsky, tom, hyc.lee, lsahlber, linux-cifs, linux-kernel
On 4/2/2023 18:10, Namjae Jeon wrote:
> 2023-02-01 17:10 GMT+09:00, Hangyu Hua <hbh25y@gmail.com>:
>> argv needs to be free when setup_async_work fails or when the current
>> process is woken up.
>>
>> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
>> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
>> ---
>> fs/ksmbd/smb2pdu.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
>> index d681f91947d9..5b7668c04f76 100644
>> --- a/fs/ksmbd/smb2pdu.c
>> +++ b/fs/ksmbd/smb2pdu.c
>> @@ -7050,6 +7050,7 @@ int smb2_lock(struct ksmbd_work *work)
>> smb2_remove_blocked_lock,
>> argv);
>> if (rc) {
>> + kfree(argv);
>> err = -ENOMEM;
>> goto out;
>> }
>> @@ -7061,6 +7062,8 @@ int smb2_lock(struct ksmbd_work *work)
>>
>> ksmbd_vfs_posix_lock_wait(flock);
>>
>> + work->cancel_fn = NULL;
>> + kfree(argv);
> This change seems to causes a NULL pointer dereference issue in
> set_close_state_blocked_works(). It is right to free it and set NULL
> after removing entry from list.
I get it. I will send a v2.
Thanks,
Hangyu
>> if (work->state != KSMBD_WORK_ACTIVE) {
>> list_del(&smb_lock->llist);
>> spin_lock(&work->conn->llist_lock);
>> --
>> 2.34.1
>>
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-06 2:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 8:10 [PATCH] ksmbd: fix possible memory leak in smb2_lock() Hangyu Hua
2023-02-04 10:10 ` Namjae Jeon
2023-02-06 2:33 ` Hangyu Hua
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®