fs: proc: fix error return code of proc_map_files_readdir()
Subsystems (2)
PATCH 1/1 fs: proc: fix error return code of proc_map_files_readdir()
When get_task_mm() returns NULL to mm, no error return code of proc_map_files_readdir() is assigned.
To fix this bug, ret is assigned with -ENOENT in this case.
--- fs/proc/base.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/proc/base.c +3 -1
@@ -2332,8 +2332,10 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) goto out_put_task; mm =get_task_mm (task); -if (!mm) +if (!mm) { + ret = -ENOENT ; goto out_put_task; + } ret =mmap_read_lock_killable (mm);if (ret) {
Signature · 1 line
2.17.1
Quoted 16 lines · Jia-Ju Bai
When
get_task_mm()returns NULL to mm, no error return code ofproc_map_files_readdir()is assigned.
To fix this bug, ret is assigned with-ENOENTin this case.Fixes f0c3b5093add ("[readdir] convert procfs")Reported-by TOTE Robot <[email protected]>Signed-off-by Jia-Ju Bai <[email protected]>--- fs/proc/base.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/proc/base.c +0
-0
fs/proc/base.c proc_map_files_readdir(struct file *file, struct dir_context *ctx) · line 2340
Quoted 10 lines
fs/proc/base.c +3
-1@@ -2332,8 +2332,10 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) goto out_put_task; mm =get_task_mm (task); -if (!mm) +if (!mm) { + ret = -ENOENT ; goto out_put_task; + } ret =mmap_read_lock_killable (mm);
Is there something in particular that makes you think that returning ENOENT is the correct behavior in this case? Try 'ls /proc/$pid/map_files' where pid is a kernel thread; it's an empty directory, which is probably intentional. Your patch would change reading the directory to fail with ENOENT.
- Eric
Quoted 17 lines · Eric Biggers
Quoted 16 lines · Jia-Ju Bai
When
get_task_mm()returns NULL to mm, no error return code ofproc_map_files_readdir()is assigned.
To fix this bug, ret is assigned with-ENOENTin this case.fs/proc/base.c +3
-1@@ -2332,8 +2332,10 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) goto out_put_task; mm =get_task_mm (task); -if (!mm) +if (!mm) { + ret = -ENOENT ; goto out_put_task; + }
Quoted 6 lines
fs/proc/base.c proc_map_files_readdir(struct file *file, struct dir_context *ctx) · line 2340
Quoted 1 line
fs/proc/base.c +0
-0ret =mmap_read_lock_killable (mm);Is there something in particular that makes you think that returning ENOENT is the correct behavior in this case? Try 'ls
/proc/$pid/map_files' where pid is a kernel thread; it's an empty directory, which is probably intentional. Your patch would change reading the directory to fail with ENOENT.
Yes. 0 from readdir means "no more stuff", not an error.
Quoted 14 lines · Alexey Dobriyan
Quoted 12 lines · Eric Biggers
Quoted 12 lines
fs/proc/base.c +3
-1@@ -2332,8 +2332,10 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) goto out_put_task; mm =get_task_mm (task); -if (!mm) +if (!mm) { + ret = -ENOENT ; goto out_put_task; + }
Quoted 6 lines
Quoted 5 lines
fs/proc/base.c proc_map_files_readdir(struct file *file, struct dir_context *ctx) · line 2340
Quoted 1 line
fs/proc/base.c +0
-0ret =mmap_read_lock_killable (mm);Is there something in particular that makes you think that returning ENOENT is the correct behavior in this case? Try 'ls
/proc/$pid/map_files' where pid is a kernel thread; it's an empty directory, which is probably intentional. Your patch would change reading the directory to fail with ENOENT.Yes. 0 from readdir means "no more stuff", not an error.
Thanks for your reply and explanation.
I am sorry for the false report...
Best wishes,
Jia-Ju Bai