linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] proc: fix dereference of ERR_PTR
@ 2016-04-06 10:07 Sudip Mukherjee
  2016-04-06 16:13 ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2016-04-06 10:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Sudip Mukherjee

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 <sudip.mukherjee@codethink.co.uk>
---
 fs/proc/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index b1755b2..a71df53 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -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;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] proc: fix dereference of ERR_PTR
  2016-04-06 10:07 [PATCH] proc: fix dereference of ERR_PTR Sudip Mukherjee
@ 2016-04-06 16:13 ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2016-04-06 16:13 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Andrew Morton, linux-kernel

On Wed, Apr 06, 2016 at 11:07:45AM +0100, Sudip Mukherjee wrote:
> 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.

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-06 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 10:07 [PATCH] proc: fix dereference of ERR_PTR Sudip Mukherjee
2016-04-06 16:13 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).