2020-10-22 17:16:25

by Zhiqiang Liu

[permalink] [raw]
Subject: [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request


In fuse_simple_request func, we will call fuse_request_alloc func to alloc
one request from fuse_req_cachep when args->force is true. However, the
return value of fuse_request_alloc func is not checked whether it is NULL.
If allocating request fails, access-NULL-pointer problem will occur.

Here, we check the return value of fuse_request_alloc func.

Fixes: 7213394c4e18 ("fuse: simplify request allocation")
Signed-off-by: Zhiqiang Liu <[email protected]>
Signed-off-by: Haotian Li <[email protected]>
---
fs/fuse/dev.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 02b3c36b3676..f7dd33ae8e31 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -481,6 +481,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
if (args->force) {
atomic_inc(&fc->num_waiting);
req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
+ if (!req)
+ return -ENOMEM;

if (!args->nocreds)
fuse_force_creds(fc, req);
--
2.19.1


2020-10-28 06:14:27

by Zhiqiang Liu

[permalink] [raw]
Subject: Re: [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request

friendly ping...

On 2020/10/22 21:13, Zhiqiang Liu wrote:
>
> In fuse_simple_request func, we will call fuse_request_alloc func to alloc
> one request from fuse_req_cachep when args->force is true. However, the
> return value of fuse_request_alloc func is not checked whether it is NULL.
> If allocating request fails, access-NULL-pointer problem will occur.
>
> Here, we check the return value of fuse_request_alloc func.
>
> Fixes: 7213394c4e18 ("fuse: simplify request allocation")
> Signed-off-by: Zhiqiang Liu <[email protected]>
> Signed-off-by: Haotian Li <[email protected]>
> ---
> fs/fuse/dev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 02b3c36b3676..f7dd33ae8e31 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -481,6 +481,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
> if (args->force) {
> atomic_inc(&fc->num_waiting);
> req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
> + if (!req)
> + return -ENOMEM;
>
> if (!args->nocreds)
> fuse_force_creds(fc, req);
>

2020-11-05 04:44:57

by Zhiqiang Liu

[permalink] [raw]
Subject: Re: [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request

Sorry for ignoring __GFP_NOFAIL flag.
Please ignore this patch.


On 2020/11/5 9:33, Zhiqiang Liu wrote:
> ping ...
>
> On 2020/10/22 21:13, Zhiqiang Liu wrote:
>>
>> In fuse_simple_request func, we will call fuse_request_alloc func to alloc
>> one request from fuse_req_cachep when args->force is true. However, the
>> return value of fuse_request_alloc func is not checked whether it is NULL.
>> If allocating request fails, access-NULL-pointer problem will occur.
>>
>> Here, we check the return value of fuse_request_alloc func.
>>
>> Fixes: 7213394c4e18 ("fuse: simplify request allocation")
>> Signed-off-by: Zhiqiang Liu <[email protected]>
>> Signed-off-by: Haotian Li <[email protected]>
>> ---
>> fs/fuse/dev.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
>> index 02b3c36b3676..f7dd33ae8e31 100644
>> --- a/fs/fuse/dev.c
>> +++ b/fs/fuse/dev.c
>> @@ -481,6 +481,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
>> if (args->force) {
>> atomic_inc(&fc->num_waiting);
>> req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
>> + if (!req)
>> + return -ENOMEM;
>>
>> if (!args->nocreds)
>> fuse_force_creds(fc, req);
>>
>
>
> .
>

2020-11-05 06:34:13

by Zhiqiang Liu

[permalink] [raw]
Subject: Re: [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request

ping ...

On 2020/10/22 21:13, Zhiqiang Liu wrote:
>
> In fuse_simple_request func, we will call fuse_request_alloc func to alloc
> one request from fuse_req_cachep when args->force is true. However, the
> return value of fuse_request_alloc func is not checked whether it is NULL.
> If allocating request fails, access-NULL-pointer problem will occur.
>
> Here, we check the return value of fuse_request_alloc func.
>
> Fixes: 7213394c4e18 ("fuse: simplify request allocation")
> Signed-off-by: Zhiqiang Liu <[email protected]>
> Signed-off-by: Haotian Li <[email protected]>
> ---
> fs/fuse/dev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 02b3c36b3676..f7dd33ae8e31 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -481,6 +481,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
> if (args->force) {
> atomic_inc(&fc->num_waiting);
> req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
> + if (!req)
> + return -ENOMEM;
>
> if (!args->nocreds)
> fuse_force_creds(fc, req);
>