All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
@ 2022-11-08 14:34 Luís Henriques
  2022-11-09  3:08 ` Xiubo Li
  0 siblings, 1 reply; 7+ messages in thread
From: Luís Henriques @ 2022-11-08 14:34 UTC (permalink / raw)
  To: Xiubo Li, Ilya Dryomov, Jeff Layton
  Cc: ceph-devel, linux-kernel, Luís Henriques

Because ceph_init_fs_context() will never be invoced in case we get a
mount error, destroy_mount_options() won't be releasing fscrypt resources
with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
an invocation to this function in the mount error path.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
* Changes since v1:

As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
ceph_real_mount().

(Also used 'git format-patch' with '--base' so that the bots know what to
(not) do with this patch.)

 fs/ceph/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 2224d44d21c0..f10a076f47e5 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
 
 out:
 	mutex_unlock(&fsc->client->mount_mutex);
+	ceph_fscrypt_free_dummy_policy(fsc);
 	return ERR_PTR(err);
 }
 

base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e

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

* Re: [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
  2022-11-08 14:34 [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption Luís Henriques
@ 2022-11-09  3:08 ` Xiubo Li
  2022-11-09  9:33   ` Luís Henriques
  0 siblings, 1 reply; 7+ messages in thread
From: Xiubo Li @ 2022-11-09  3:08 UTC (permalink / raw)
  To: Luís Henriques, Ilya Dryomov, Jeff Layton; +Cc: ceph-devel, linux-kernel


On 08/11/2022 22:34, Luís Henriques wrote:
> Because ceph_init_fs_context() will never be invoced in case we get a
> mount error, destroy_mount_options() won't be releasing fscrypt resources
> with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
> an invocation to this function in the mount error path.
>
> Signed-off-by: Luís Henriques <lhenriques@suse.de>
> ---
> * Changes since v1:
>
> As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
> ceph_real_mount().
>
> (Also used 'git format-patch' with '--base' so that the bots know what to
> (not) do with this patch.)
>
>   fs/ceph/super.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index 2224d44d21c0..f10a076f47e5 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
>   
>   out:
>   	mutex_unlock(&fsc->client->mount_mutex);
> +	ceph_fscrypt_free_dummy_policy(fsc);
>   	return ERR_PTR(err);
>   }
>   
>
> base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
> prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
> prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
> prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e
>
LGTM.

Thanks Luis.

Could I fold this into the previous commit ?

BRs

- Xiubo



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

* Re: [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
  2022-11-09  3:08 ` Xiubo Li
@ 2022-11-09  9:33   ` Luís Henriques
  2022-11-09  9:40     ` Xiubo Li
  2022-11-09  9:57     ` Xiubo Li
  0 siblings, 2 replies; 7+ messages in thread
From: Luís Henriques @ 2022-11-09  9:33 UTC (permalink / raw)
  To: Xiubo Li; +Cc: Ilya Dryomov, Jeff Layton, ceph-devel, linux-kernel

On Wed, Nov 09, 2022 at 11:08:49AM +0800, Xiubo Li wrote:
> 
> On 08/11/2022 22:34, Luís Henriques wrote:
> > Because ceph_init_fs_context() will never be invoced in case we get a
> > mount error, destroy_mount_options() won't be releasing fscrypt resources
> > with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
> > an invocation to this function in the mount error path.
> > 
> > Signed-off-by: Luís Henriques <lhenriques@suse.de>
> > ---
> > * Changes since v1:
> > 
> > As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
> > ceph_real_mount().
> > 
> > (Also used 'git format-patch' with '--base' so that the bots know what to
> > (not) do with this patch.)
> > 
> >   fs/ceph/super.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> > index 2224d44d21c0..f10a076f47e5 100644
> > --- a/fs/ceph/super.c
> > +++ b/fs/ceph/super.c
> > @@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
> >   out:
> >   	mutex_unlock(&fsc->client->mount_mutex);
> > +	ceph_fscrypt_free_dummy_policy(fsc);
> >   	return ERR_PTR(err);
> >   }
> > 
> > base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
> > prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
> > prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
> > prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e
> > 
> LGTM.
> 
> Thanks Luis.
> 
> Could I fold this into the previous commit ?

Yes, sure.  I'm fine with that.

Cheers,
--
Luís

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

* Re: [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
  2022-11-09  9:33   ` Luís Henriques
@ 2022-11-09  9:40     ` Xiubo Li
  2022-11-09  9:57     ` Xiubo Li
  1 sibling, 0 replies; 7+ messages in thread
From: Xiubo Li @ 2022-11-09  9:40 UTC (permalink / raw)
  To: Luís Henriques; +Cc: Ilya Dryomov, Jeff Layton, ceph-devel, linux-kernel


On 09/11/2022 17:33, Luís Henriques wrote:
> On Wed, Nov 09, 2022 at 11:08:49AM +0800, Xiubo Li wrote:
>> On 08/11/2022 22:34, Luís Henriques wrote:
>>> Because ceph_init_fs_context() will never be invoced in case we get a
>>> mount error, destroy_mount_options() won't be releasing fscrypt resources
>>> with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
>>> an invocation to this function in the mount error path.
>>>
>>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>>> ---
>>> * Changes since v1:
>>>
>>> As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
>>> ceph_real_mount().
>>>
>>> (Also used 'git format-patch' with '--base' so that the bots know what to
>>> (not) do with this patch.)
>>>
>>>    fs/ceph/super.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
>>> index 2224d44d21c0..f10a076f47e5 100644
>>> --- a/fs/ceph/super.c
>>> +++ b/fs/ceph/super.c
>>> @@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
>>>    out:
>>>    	mutex_unlock(&fsc->client->mount_mutex);
>>> +	ceph_fscrypt_free_dummy_policy(fsc);
>>>    	return ERR_PTR(err);
>>>    }
>>>
>>> base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
>>> prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
>>> prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
>>> prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e
>>>
>> LGTM.
>>
>> Thanks Luis.
>>
>> Could I fold this into the previous commit ?
> Yes, sure.  I'm fine with that.

Thanks.

I will mentioned this fix in that commit comments.

- Xiubo


>
> Cheers,
> --
> Luís
>


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

* Re: [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
  2022-11-09  9:33   ` Luís Henriques
  2022-11-09  9:40     ` Xiubo Li
@ 2022-11-09  9:57     ` Xiubo Li
  2022-11-09 10:38       ` Luís Henriques
  1 sibling, 1 reply; 7+ messages in thread
From: Xiubo Li @ 2022-11-09  9:57 UTC (permalink / raw)
  To: Luís Henriques; +Cc: Ilya Dryomov, Jeff Layton, ceph-devel, linux-kernel

Hi Luis,

Please check 
https://github.com/ceph/ceph-client/commit/205efda80b6759a741dde209a7158a5bbf044d23#diff-eb62c69f842ed95a7d047262a62946b07eda52f2ea49ae33c39ea13754dfc291.

Currently I only applied it into the 'testing' branch.

Thanks!

- Xiubo


On 09/11/2022 17:33, Luís Henriques wrote:
> On Wed, Nov 09, 2022 at 11:08:49AM +0800, Xiubo Li wrote:
>> On 08/11/2022 22:34, Luís Henriques wrote:
>>> Because ceph_init_fs_context() will never be invoced in case we get a
>>> mount error, destroy_mount_options() won't be releasing fscrypt resources
>>> with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
>>> an invocation to this function in the mount error path.
>>>
>>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>>> ---
>>> * Changes since v1:
>>>
>>> As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
>>> ceph_real_mount().
>>>
>>> (Also used 'git format-patch' with '--base' so that the bots know what to
>>> (not) do with this patch.)
>>>
>>>    fs/ceph/super.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
>>> index 2224d44d21c0..f10a076f47e5 100644
>>> --- a/fs/ceph/super.c
>>> +++ b/fs/ceph/super.c
>>> @@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
>>>    out:
>>>    	mutex_unlock(&fsc->client->mount_mutex);
>>> +	ceph_fscrypt_free_dummy_policy(fsc);
>>>    	return ERR_PTR(err);
>>>    }
>>>
>>> base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
>>> prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
>>> prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
>>> prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e
>>>
>> LGTM.
>>
>> Thanks Luis.
>>
>> Could I fold this into the previous commit ?
> Yes, sure.  I'm fine with that.
>
> Cheers,
> --
> Luís
>


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

* Re: [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
  2022-11-09  9:57     ` Xiubo Li
@ 2022-11-09 10:38       ` Luís Henriques
  2022-11-09 14:01         ` Xiubo Li
  0 siblings, 1 reply; 7+ messages in thread
From: Luís Henriques @ 2022-11-09 10:38 UTC (permalink / raw)
  To: Xiubo Li; +Cc: Ilya Dryomov, Jeff Layton, ceph-devel, linux-kernel

On Wed, Nov 09, 2022 at 05:57:41PM +0800, Xiubo Li wrote:
> Hi Luis,
> 
> Please check https://github.com/ceph/ceph-client/commit/205efda80b6759a741dde209a7158a5bbf044d23#diff-eb62c69f842ed95a7d047262a62946b07eda52f2ea49ae33c39ea13754dfc291.

Ugh! That's quite confusing :-)

I did a 'git fetch' and looked into commit 205efda80b67 ("ceph: implement
-o test_dummy_encryption mount option") instead, and compared it with it's
version in the wip-fscrypt branch.  It looks good to me: the only
difference I see is my fix (adding the 'ceph_fscrypt_free_dummy_policy'
call to 'ceph_real_mount').  Thanks!

Cheers,
--
Luís

> 
> Currently I only applied it into the 'testing' branch.
> 
> Thanks!
> 
> - Xiubo
> 
> 
> On 09/11/2022 17:33, Luís Henriques wrote:
> > On Wed, Nov 09, 2022 at 11:08:49AM +0800, Xiubo Li wrote:
> > > On 08/11/2022 22:34, Luís Henriques wrote:
> > > > Because ceph_init_fs_context() will never be invoced in case we get a
> > > > mount error, destroy_mount_options() won't be releasing fscrypt resources
> > > > with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
> > > > an invocation to this function in the mount error path.
> > > > 
> > > > Signed-off-by: Luís Henriques <lhenriques@suse.de>
> > > > ---
> > > > * Changes since v1:
> > > > 
> > > > As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
> > > > ceph_real_mount().
> > > > 
> > > > (Also used 'git format-patch' with '--base' so that the bots know what to
> > > > (not) do with this patch.)
> > > > 
> > > >    fs/ceph/super.c | 1 +
> > > >    1 file changed, 1 insertion(+)
> > > > 
> > > > diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> > > > index 2224d44d21c0..f10a076f47e5 100644
> > > > --- a/fs/ceph/super.c
> > > > +++ b/fs/ceph/super.c
> > > > @@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
> > > >    out:
> > > >    	mutex_unlock(&fsc->client->mount_mutex);
> > > > +	ceph_fscrypt_free_dummy_policy(fsc);
> > > >    	return ERR_PTR(err);
> > > >    }
> > > > 
> > > > base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
> > > > prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
> > > > prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
> > > > prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e
> > > > 
> > > LGTM.
> > > 
> > > Thanks Luis.
> > > 
> > > Could I fold this into the previous commit ?
> > Yes, sure.  I'm fine with that.
> > 
> > Cheers,
> > --
> > Luís
> > 
> 

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

* Re: [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption
  2022-11-09 10:38       ` Luís Henriques
@ 2022-11-09 14:01         ` Xiubo Li
  0 siblings, 0 replies; 7+ messages in thread
From: Xiubo Li @ 2022-11-09 14:01 UTC (permalink / raw)
  To: Luís Henriques; +Cc: Ilya Dryomov, Jeff Layton, ceph-devel, linux-kernel


On 09/11/2022 18:38, Luís Henriques wrote:
> On Wed, Nov 09, 2022 at 05:57:41PM +0800, Xiubo Li wrote:
>> Hi Luis,
>>
>> Please check https://github.com/ceph/ceph-client/commit/205efda80b6759a741dde209a7158a5bbf044d23#diff-eb62c69f842ed95a7d047262a62946b07eda52f2ea49ae33c39ea13754dfc291.
> Ugh! That's quite confusing :-)
>
> I did a 'git fetch' and looked into commit 205efda80b67 ("ceph: implement
> -o test_dummy_encryption mount option") instead, and compared it with it's
> version in the wip-fscrypt branch.  It looks good to me: the only
> difference I see is my fix (adding the 'ceph_fscrypt_free_dummy_policy'
> call to 'ceph_real_mount').  Thanks!

I will update the wip-fscrypt branch later.

Thanks!


> Cheers,
> --
> Luís
>
>> Currently I only applied it into the 'testing' branch.
>>
>> Thanks!
>>
>> - Xiubo
>>
>>
>> On 09/11/2022 17:33, Luís Henriques wrote:
>>> On Wed, Nov 09, 2022 at 11:08:49AM +0800, Xiubo Li wrote:
>>>> On 08/11/2022 22:34, Luís Henriques wrote:
>>>>> Because ceph_init_fs_context() will never be invoced in case we get a
>>>>> mount error, destroy_mount_options() won't be releasing fscrypt resources
>>>>> with fscrypt_free_dummy_policy().  This will result in a memory leak.  Add
>>>>> an invocation to this function in the mount error path.
>>>>>
>>>>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>>>>> ---
>>>>> * Changes since v1:
>>>>>
>>>>> As suggested by Xiubo, moved fscrypt free from ceph_get_tree() to
>>>>> ceph_real_mount().
>>>>>
>>>>> (Also used 'git format-patch' with '--base' so that the bots know what to
>>>>> (not) do with this patch.)
>>>>>
>>>>>     fs/ceph/super.c | 1 +
>>>>>     1 file changed, 1 insertion(+)
>>>>>
>>>>> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
>>>>> index 2224d44d21c0..f10a076f47e5 100644
>>>>> --- a/fs/ceph/super.c
>>>>> +++ b/fs/ceph/super.c
>>>>> @@ -1196,6 +1196,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
>>>>>     out:
>>>>>     	mutex_unlock(&fsc->client->mount_mutex);
>>>>> +	ceph_fscrypt_free_dummy_policy(fsc);
>>>>>     	return ERR_PTR(err);
>>>>>     }
>>>>>
>>>>> base-commit: 8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
>>>>> prerequisite-patch-id: 34ba9e6b37b68668d261ddbda7858ee6f83c82fa
>>>>> prerequisite-patch-id: 87f1b323c29ab8d0a6d012d30fdc39bc49179624
>>>>> prerequisite-patch-id: c94f448ef026375b10748457a3aa46070aa7046e
>>>>>
>>>> LGTM.
>>>>
>>>> Thanks Luis.
>>>>
>>>> Could I fold this into the previous commit ?
>>> Yes, sure.  I'm fine with that.
>>>
>>> Cheers,
>>> --
>>> Luís
>>>


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

end of thread, other threads:[~2022-11-09 14:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 14:34 [PATCH v2] ceph: fix memory leak in mount error path when using test_dummy_encryption Luís Henriques
2022-11-09  3:08 ` Xiubo Li
2022-11-09  9:33   ` Luís Henriques
2022-11-09  9:40     ` Xiubo Li
2022-11-09  9:57     ` Xiubo Li
2022-11-09 10:38       ` Luís Henriques
2022-11-09 14:01         ` Xiubo Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.