Skip to contentSkip to conversation

fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request

PATCH In review Zhiqiang Liu 1 participant 4 messages Oct 22, 2020 – Nov 5, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 fs/fuse/dev.c | 2 ++
 1 file changed, 2 insertions(+)
fs/fuse/dev.c +2 -0
index 02b3c36b3676..f7dd33ae8e31 100644
@@ -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);
Signature · 1 line
2.19.1
#1 lore raw

friendly ping...

Quoted 29 lines · Zhiqiang Liu

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")
---
 fs/fuse/dev.c | 2 ++
 1 file changed, 2 insertions(+)
fs/fuse/dev.c +2 -0
index 02b3c36b3676..f7dd33ae8e31 100644
@@ -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 lore raw
In reply to Zhiqiang Liu

ping ...

Quoted 29 lines · Zhiqiang Liu

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")
---
 fs/fuse/dev.c | 2 ++
 1 file changed, 2 insertions(+)
fs/fuse/dev.c +2 -0
index 02b3c36b3676..f7dd33ae8e31 100644
@@ -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);
#3 lore raw

Sorry for ignoring __GFP_NOFAIL flag.
Please ignore this patch.

Quoted 36 lines · Zhiqiang Liu

ping ...

Quoted 21 lines · Zhiqiang Liu

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")
---
 fs/fuse/dev.c | 2 ++
 1 file changed, 2 insertions(+)
fs/fuse/dev.c +0 -0
index 02b3c36b3676..f7dd33ae8e31 100644

fs/fuse/dev.c ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args) · line 488

Quoted 8 lines
fs/fuse/dev.c +2 -0
@@ -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);

.