proc: fix dereference of ERR_PTR
PATCH 1/1 proc: fix dereference of ERR_PTR
On the unlikely event of a bad name, d_hash_and_lookup() can return the error value in ERR_PTR(). And we were only checking the return value of d_hash_and_lookup() to be NULL. In case it is not NULL and has some error then d_inode() will try to dereference it later.
Signed-off-by Sudip Mukherjee <[email protected]>
--- fs/proc/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/base.c +1 -1
@@ -1818,7 +1818,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
2.1.4
Quoted 4 lines · Sudip Mukherjee
On the unlikely event of a bad name,
d_hash_and_lookup()can return the error value inERR_PTR(). And we were only checking the return value ofd_hash_and_lookup()to be NULL. In case it is not NULL and has some error thend_inode()will try to dereference it later.
s/unlikely/impossible/ - procfs doesn't _have_ ->d_hash. NAK; at most add a
/* no ->d_hash() rejects on procfs */
comment as we have next to another call site in procfs.