linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ksmbd: fix possible refcount leak in smb2_open()
@ 2023-03-02 13:58 ChenXiaoSong
  2023-03-07  8:52 ` ChenXiaoSong
  2023-03-07  9:23 ` Namjae Jeon
  0 siblings, 2 replies; 4+ messages in thread
From: ChenXiaoSong @ 2023-03-02 13:58 UTC (permalink / raw)
  To: linkinjeon, sfrench, senozhatsky, lsahlber, hyc.lee
  Cc: linux-cifs, linux-kernel, chenxiaosong2, yi.zhang, zhangxiaoxu5,
	yanaijie

Reference count of acls will leak when memory allocation fails. Fix this
by adding the missing posix_acl_release().

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
---
 fs/ksmbd/smb2pdu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index 0685c1c77b9f..f04d810a2588 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -2977,8 +2977,11 @@ int smb2_open(struct ksmbd_work *work)
 							sizeof(struct smb_acl) +
 							sizeof(struct smb_ace) * ace_num * 2,
 							GFP_KERNEL);
-					if (!pntsd)
+					if (!pntsd) {
+						posix_acl_release(fattr.cf_acls);
+						posix_acl_release(fattr.cf_dacls);
 						goto err_out;
+					}
 
 					rc = build_sec_desc(idmap,
 							    pntsd, NULL, 0,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ksmbd: fix possible refcount leak in smb2_open()
  2023-03-02 13:58 [PATCH] ksmbd: fix possible refcount leak in smb2_open() ChenXiaoSong
@ 2023-03-07  8:52 ` ChenXiaoSong
  2023-03-07  9:27   ` Namjae Jeon
  2023-03-07  9:23 ` Namjae Jeon
  1 sibling, 1 reply; 4+ messages in thread
From: ChenXiaoSong @ 2023-03-07  8:52 UTC (permalink / raw)
  To: linkinjeon, sfrench, stfrench; +Cc: linux-cifs, linux-kernel

Hi Namjae and Steve:

Do you have any suggestions for this patch?

在 2023/3/2 21:58, ChenXiaoSong 写道:
> Reference count of acls will leak when memory allocation fails. Fix this
> by adding the missing posix_acl_release().
> 
> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
> Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
> ---
>   fs/ksmbd/smb2pdu.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index 0685c1c77b9f..f04d810a2588 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -2977,8 +2977,11 @@ int smb2_open(struct ksmbd_work *work)
>   							sizeof(struct smb_acl) +
>   							sizeof(struct smb_ace) * ace_num * 2,
>   							GFP_KERNEL);
> -					if (!pntsd)
> +					if (!pntsd) {
> +						posix_acl_release(fattr.cf_acls);
> +						posix_acl_release(fattr.cf_dacls);
>   						goto err_out;
> +					}
>   
>   					rc = build_sec_desc(idmap,
>   							    pntsd, NULL, 0,
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ksmbd: fix possible refcount leak in smb2_open()
  2023-03-02 13:58 [PATCH] ksmbd: fix possible refcount leak in smb2_open() ChenXiaoSong
  2023-03-07  8:52 ` ChenXiaoSong
@ 2023-03-07  9:23 ` Namjae Jeon
  1 sibling, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2023-03-07  9:23 UTC (permalink / raw)
  To: ChenXiaoSong
  Cc: sfrench, senozhatsky, lsahlber, hyc.lee, linux-cifs,
	linux-kernel, yi.zhang, zhangxiaoxu5, yanaijie

2023-03-02 22:58 GMT+09:00, ChenXiaoSong <chenxiaosong2@huawei.com>:
> Reference count of acls will leak when memory allocation fails. Fix this
> by adding the missing posix_acl_release().
>
> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
> Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>

Thanks for your patch!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ksmbd: fix possible refcount leak in smb2_open()
  2023-03-07  8:52 ` ChenXiaoSong
@ 2023-03-07  9:27   ` Namjae Jeon
  0 siblings, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2023-03-07  9:27 UTC (permalink / raw)
  To: ChenXiaoSong; +Cc: sfrench, stfrench, linux-cifs, linux-kernel

2023-03-07 17:52 GMT+09:00, ChenXiaoSong <chenxiaosong2@huawei.com>:
> Hi Namjae and Steve:
Hi Chen,
>
> Do you have any suggestions for this patch?
Sorry, It was in the spam box...
I have sent ack. Thanks for noticing.
>
> 在 2023/3/2 21:58, ChenXiaoSong 写道:
>> Reference count of acls will leak when memory allocation fails. Fix this
>> by adding the missing posix_acl_release().
>>
>> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
>> Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
>> ---
>>   fs/ksmbd/smb2pdu.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
>> index 0685c1c77b9f..f04d810a2588 100644
>> --- a/fs/ksmbd/smb2pdu.c
>> +++ b/fs/ksmbd/smb2pdu.c
>> @@ -2977,8 +2977,11 @@ int smb2_open(struct ksmbd_work *work)
>>   							sizeof(struct smb_acl) +
>>   							sizeof(struct smb_ace) * ace_num * 2,
>>   							GFP_KERNEL);
>> -					if (!pntsd)
>> +					if (!pntsd) {
>> +						posix_acl_release(fattr.cf_acls);
>> +						posix_acl_release(fattr.cf_dacls);
>>   						goto err_out;
>> +					}
>>
>>   					rc = build_sec_desc(idmap,
>>   							    pntsd, NULL, 0,
>>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-07  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-02 13:58 [PATCH] ksmbd: fix possible refcount leak in smb2_open() ChenXiaoSong
2023-03-07  8:52 ` ChenXiaoSong
2023-03-07  9:27   ` Namjae Jeon
2023-03-07  9:23 ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).