diff mbox series

ceph: fix the buf size and use NAME_SIZE instead

Message ID 20220316035100.68406-1-xiubli@redhat.com (mailing list archive)
State New, archived
Headers show
Series ceph: fix the buf size and use NAME_SIZE instead | expand

Commit Message

Xiubo Li March 16, 2022, 3:51 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

Since the base64_encrypted file name shouldn't exceed the NAME_SIZE,
no need to allocate a buffer from the stack that long.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---

Jeff, you can just squash this into the previous commit.


 fs/ceph/mds_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Venky Shankar March 16, 2022, 4:15 a.m. UTC | #1
On Wed, Mar 16, 2022 at 9:21 AM <xiubli@redhat.com> wrote:
>
> From: Xiubo Li <xiubli@redhat.com>
>
> Since the base64_encrypted file name shouldn't exceed the NAME_SIZE,
> no need to allocate a buffer from the stack that long.
>
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>
> Jeff, you can just squash this into the previous commit.
>
>
>  fs/ceph/mds_client.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index c51b07ec72cf..cd0c780a6f84 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -2579,7 +2579,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase, int for
>                         parent = dget_parent(cur);
>                 } else {
>                         int len, ret;
> -                       char buf[FSCRYPT_BASE64URL_CHARS(NAME_MAX)];
> +                       char buf[NAME_MAX];
>
>                         /*
>                          * Proactively copy name into buf, in case we need to present
> --
> 2.27.0
>

Makes sense.

Acked-by: Venky Shankar <vshankar@redhat.com>
Jeffrey Layton March 16, 2022, 11:50 a.m. UTC | #2
On Wed, 2022-03-16 at 11:51 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
> 
> Since the base64_encrypted file name shouldn't exceed the NAME_SIZE,
> no need to allocate a buffer from the stack that long.
> 
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
> 
> Jeff, you can just squash this into the previous commit.
> 
> 
>  fs/ceph/mds_client.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index c51b07ec72cf..cd0c780a6f84 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -2579,7 +2579,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase, int for
>  			parent = dget_parent(cur);
>  		} else {
>  			int len, ret;
> -			char buf[FSCRYPT_BASE64URL_CHARS(NAME_MAX)];
> +			char buf[NAME_MAX];
>  
>  			/*
>  			 * Proactively copy name into buf, in case we need to present

Thanks Xiubo. I folded this into:

    ceph: add encrypted fname handling to ceph_mdsc_build_path

...and merged in the other patches you sent earlier today.

I also went ahead and squashed down the readdir patches that you sent
yesterday, so that we could get rid of the interim readdir handling that
I had originally written.

It might need a bit more cleanup -- some of the deltas in the merged
patch probably belong in earlier commits, but it should be ok for now.

Please take a look and make sure I didn't miss anything there.
Xiubo Li March 17, 2022, 1 a.m. UTC | #3
On 3/16/22 7:50 PM, Jeff Layton wrote:
> On Wed, 2022-03-16 at 11:51 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> Since the base64_encrypted file name shouldn't exceed the NAME_SIZE,
>> no need to allocate a buffer from the stack that long.
>>
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>
>> Jeff, you can just squash this into the previous commit.
>>
>>
>>   fs/ceph/mds_client.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
>> index c51b07ec72cf..cd0c780a6f84 100644
>> --- a/fs/ceph/mds_client.c
>> +++ b/fs/ceph/mds_client.c
>> @@ -2579,7 +2579,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase, int for
>>   			parent = dget_parent(cur);
>>   		} else {
>>   			int len, ret;
>> -			char buf[FSCRYPT_BASE64URL_CHARS(NAME_MAX)];
>> +			char buf[NAME_MAX];
>>   
>>   			/*
>>   			 * Proactively copy name into buf, in case we need to present
> Thanks Xiubo. I folded this into:
>
>      ceph: add encrypted fname handling to ceph_mdsc_build_path
>
> ...and merged in the other patches you sent earlier today.
>
> I also went ahead and squashed down the readdir patches that you sent
> yesterday, so that we could get rid of the interim readdir handling that
> I had originally written.
>
> It might need a bit more cleanup -- some of the deltas in the merged
> patch probably belong in earlier commits, but it should be ok for now.
>
> Please take a look and make sure I didn't miss anything there.

Sure, will check it today.

- Xiubo
Xiubo Li March 18, 2022, 6:03 a.m. UTC | #4
On 3/16/22 7:50 PM, Jeff Layton wrote:
> On Wed, 2022-03-16 at 11:51 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> Since the base64_encrypted file name shouldn't exceed the NAME_SIZE,
>> no need to allocate a buffer from the stack that long.
>>
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>
>> Jeff, you can just squash this into the previous commit.
>>
>>
>>   fs/ceph/mds_client.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
>> index c51b07ec72cf..cd0c780a6f84 100644
>> --- a/fs/ceph/mds_client.c
>> +++ b/fs/ceph/mds_client.c
>> @@ -2579,7 +2579,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase, int for
>>   			parent = dget_parent(cur);
>>   		} else {
>>   			int len, ret;
>> -			char buf[FSCRYPT_BASE64URL_CHARS(NAME_MAX)];
>> +			char buf[NAME_MAX];
>>   
>>   			/*
>>   			 * Proactively copy name into buf, in case we need to present
> Thanks Xiubo. I folded this into:
>
>      ceph: add encrypted fname handling to ceph_mdsc_build_path
>
> ...and merged in the other patches you sent earlier today.
>
> I also went ahead and squashed down the readdir patches that you sent
> yesterday, so that we could get rid of the interim readdir handling that
> I had originally written.
>
> It might need a bit more cleanup -- some of the deltas in the merged
> patch probably belong in earlier commits, but it should be ok for now.
>
> Please take a look and make sure I didn't miss anything there.

I have gone through the wip-fscrypt, all these look fine.

-- Xiubo
diff mbox series

Patch

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index c51b07ec72cf..cd0c780a6f84 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -2579,7 +2579,7 @@  char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase, int for
 			parent = dget_parent(cur);
 		} else {
 			int len, ret;
-			char buf[FSCRYPT_BASE64URL_CHARS(NAME_MAX)];
+			char buf[NAME_MAX];
 
 			/*
 			 * Proactively copy name into buf, in case we need to present