ceph: fix memory leak in mount error path when using test_dummy_encryption
PATCH v2 1/1 ceph: fix memory leak in mount error path when using test_dummy_encryption
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.
---
* 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(+)
fs/ceph/super.c +1 -0
@@ -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
Quoted 31 lines · 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 withfscrypt_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 <[email protected]>---
* Changes since v1:As suggested by Xiubo, moved fscrypt free from
ceph_get_tree()toceph_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(+)fs/ceph/super.c +1
-0@@ -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); }
Quoted 5 lines
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
Quoted 38 lines · Xiubo Li
Quoted 29 lines · 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 withfscrypt_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 <[email protected]>---
* Changes since v1:As suggested by Xiubo, moved fscrypt free from
ceph_get_tree()toceph_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(+)fs/ceph/super.c +1
-0@@ -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); }Quoted 5 lines
base-commit:
8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
prerequisite-patch-id:34ba9e6b37b68668d261ddbda7858ee6f83c82fa
prerequisite-patch-id:87f1b323c29ab8d0a6d012d30fdc39bc49179624
prerequisite-patch-id:c94f448ef026375b10748457a3aa46070aa7046eLGTM.
Quoted 3 lines
Thanks Luis.
Could I fold this into the previous commit ?
Yes, sure. I'm fine with that.
Cheers,
--
Luís
Quoted 38 lines · Luís Henriques
Quoted 37 lines · Xiubo Li
Quoted 29 lines · 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 withfscrypt_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 <[email protected]>---
* Changes since v1:As suggested by Xiubo, moved fscrypt free from
ceph_get_tree()toceph_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(+)fs/ceph/super.c +1
-0@@ -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); }Quoted 5 lines
base-commit:
8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
prerequisite-patch-id:34ba9e6b37b68668d261ddbda7858ee6f83c82fa
prerequisite-patch-id:87f1b323c29ab8d0a6d012d30fdc39bc49179624
prerequisite-patch-id:c94f448ef026375b10748457a3aa46070aa7046eLGTM.
Quoted 4 lines
Quoted 3 lines
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
Quoted 5 lines
Cheers,
--
Luís
Hi Luis,
Currently I only applied it into the 'testing' branch.
Thanks!
- Xiubo
Quoted 47 lines · Luís Henriques
Quoted 37 lines · Xiubo Li
Quoted 29 lines · 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 withfscrypt_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 <[email protected]>---
* Changes since v1:As suggested by Xiubo, moved fscrypt free from
ceph_get_tree()toceph_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(+)fs/ceph/super.c +1
-0@@ -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); }Quoted 5 lines
base-commit:
8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
prerequisite-patch-id:34ba9e6b37b68668d261ddbda7858ee6f83c82fa
prerequisite-patch-id:87f1b323c29ab8d0a6d012d30fdc39bc49179624
prerequisite-patch-id:c94f448ef026375b10748457a3aa46070aa7046eLGTM.
Quoted 3 lines
Thanks Luis.
Could I fold this into the previous commit ?
Yes, sure. I'm fine with that.
Cheers,
--
Luís
Quoted 3 lines · Xiubo Li
Hi Luis,
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
Quoted 57 lines
Currently I only applied it into the 'testing' branch.
Thanks!
- Xiubo
Quoted 47 lines · Luís Henriques
Quoted 37 lines · Xiubo Li
Quoted 29 lines · 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 withfscrypt_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 <[email protected]>---
* Changes since v1:As suggested by Xiubo, moved fscrypt free from
ceph_get_tree()toceph_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(+)fs/ceph/super.c +1
-0@@ -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); }Quoted 5 lines
base-commit:
8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
prerequisite-patch-id:34ba9e6b37b68668d261ddbda7858ee6f83c82fa
prerequisite-patch-id:87f1b323c29ab8d0a6d012d30fdc39bc49179624
prerequisite-patch-id:c94f448ef026375b10748457a3aa46070aa7046eLGTM.
Quoted 3 lines
Thanks Luis.
Could I fold this into the previous commit ?
Yes, sure. I'm fine with that.
Cheers,
--
Luís
Quoted 11 lines · Luís Henriques
Quoted 3 lines · Xiubo Li
Hi Luis,
Ugh! That's quite confusing :-)
I did a 'git fetch' and looked into commit
205efda80b67("ceph: implement -otest_dummy_encryptionmount 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!
Quoted 59 lines
Cheers,
--
LuísQuoted 55 lines
Currently I only applied it into the 'testing' branch.
Thanks!
- Xiubo
Quoted 47 lines · Luís Henriques
Quoted 37 lines · Xiubo Li
Quoted 29 lines · 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 withfscrypt_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 <[email protected]>---
* Changes since v1:As suggested by Xiubo, moved fscrypt free from
ceph_get_tree()toceph_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(+)fs/ceph/super.c +1
-0@@ -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); }Quoted 5 lines
base-commit:
8b9ee21dfceadd4cc35a87bbe7f0ad547cffa1be
prerequisite-patch-id:34ba9e6b37b68668d261ddbda7858ee6f83c82fa
prerequisite-patch-id:87f1b323c29ab8d0a6d012d30fdc39bc49179624
prerequisite-patch-id:c94f448ef026375b10748457a3aa46070aa7046eLGTM.
Quoted 3 lines
Thanks Luis.
Could I fold this into the previous commit ?
Yes, sure. I'm fine with that.
Cheers,
--
Luís