proc: potential ERR_PTR dereference on proc_fill_cache()
PATCH 1/1 proc: potential ERR_PTR dereference on proc_fill_cache()
The d_hash_and_lookup() returns NULL or ERR_PTR on lookup failure.
--- fs/proc/base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/proc/base.c +1 -1
@@ -1673,7 +1673,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino; child =d_hash_and_lookup (dir, &qname); -if (!child) { +if (IS_ERR_OR_NULL (child)) { child =d_alloc (dir, &qname);if (!child) goto end_instantiate;
Signature · 1 line
1.7.1
Quoted 2 lines · Daeseok Youn
The
d_hash_and_lookup()returns NULL orERR_PTRon lookup failure.
Given that the only error condition can come from .d_hash and that proc does not implement .d_hash if we want to do something with error returns let's call BUG_ON. aka:
fs/proc/base.c +1 -0
@@ -1673,7 +1673,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino; child =d_hash_and_lookup (dir, &qname); +BUG_ON (IS_ERR (child))
if (!child) { child = d_alloc(dir, &qname);
if (!child)
goto end_instantiate;
Or do you see something in d_hash_and_lookup that I am overlooking?
Eric
Quoted 18 lines
Signed-off-by Daeseok Youn <[email protected]>--- fs/proc/base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/proc/base.c +1
-1@@ -1673,7 +1673,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino; child =d_hash_and_lookup (dir, &qname); -if (!child) { +if (IS_ERR_OR_NULL (child)) { child =d_alloc (dir, &qname);if (!child) goto end_instantiate;
2014-08-11 12:25 GMT+09:00 Eric W. Biederman <[email protected]>:
Quoted 8 lines
Quoted 2 lines · Daeseok Youn
The
d_hash_and_lookup()returns NULL orERR_PTRon lookup failure.Given that the only error condition can come from .d_hash and that proc does not implement .d_hash if we want to do something with error returns let's call
BUG_ON. aka:
Yes, you're right. proc doesn't implement .d_hash, so my patch is not needed. It couldn't return ERR_PTR(-error) without implementing .d_hash This patch should be dropped.
Quoted 15 lines
fs/proc/base.c +1
-0@@ -1673,7 +1673,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino; child =d_hash_and_lookup (dir, &qname); +BUG_ON (IS_ERR(child )) if (!child) { child =d_alloc (dir, &qname);if (!child) goto end_instantiate;
Quoted 1 line
Or do you see something in
d_hash_and_lookupthat I am overlooking?
No.. I should check more carefully. sorry for that.
Thanks for review.
regards,
Daeseok Youn.
Quoted 22 lines
Eric
Quoted 18 lines
Signed-off-by Daeseok Youn <[email protected]>--- fs/proc/base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/proc/base.c +1
-1@@ -1673,7 +1673,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino; child =d_hash_and_lookup (dir, &qname); -if (!child) { +if (IS_ERR_OR_NULL (child)) { child =d_alloc (dir, &qname);if (!child) goto end_instantiate;