mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Daeseok Youn <daeseok.youn@gmail.com>
Cc: akpm@linux-foundation.org, oleg@redhat.com, eparis@redhat.com,
	rgb@redhat.com, tixxdz@opendz.org, adobriyan@gmail.com,
	bill.c.roberts@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] proc: potential ERR_PTR dereference on proc_fill_cache()
Date: Sun, 10 Aug 2014 20:25:39 -0700	[thread overview]
Message-ID: <8738d3hfm4.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20140811024720.GA11337@devel.8.8.4.4> (Daeseok Youn's message of "Mon, 11 Aug 2014 11:47:20 +0900")

Daeseok Youn <daeseok.youn@gmail.com> writes:

> The d_hash_and_lookup() returns NULL or ERR_PTR on 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:

diff --git a/fs/proc/base.c b/fs/proc/base.c
index f50d4be..49bc09c 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -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


> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
>  fs/proc/base.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index f50d4be..49bc09c 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -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;

  reply	other threads:[~2014-08-11  3:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11  2:47 Daeseok Youn
2014-08-11  3:25 ` Eric W. Biederman [this message]
2014-08-11  5:43   ` DaeSeok Youn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738d3hfm4.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bill.c.roberts@gmail.com \
    --cc=daeseok.youn@gmail.com \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=rgb@redhat.com \
    --cc=tixxdz@opendz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®