mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: kernfs: Fix possible null-pointer dereferences in kernfs_path_from_node_locked()
Date: Mon, 29 Jul 2019 11:51:33 -0700	[thread overview]
Message-ID: <20190729185133.GD569612@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <20190724022242.27505-1-baijiaju1990@gmail.com>

On Wed, Jul 24, 2019 at 10:22:42AM +0800, Jia-Ju Bai wrote:
> In kernfs_path_from_node_locked(), there is an if statement on line 147
> to check whether buf is NULL:
>     if (buf)
> 
> When buf is NULL, it is used on line 151:
>     len += strlcpy(buf + len, parent_str, ...)
> and line 158:
>     len += strlcpy(buf + len, "/", ...)
> and line 160:
>     len += strlcpy(buf + len, kn->name, ...)
> 
> Thus, possible null-pointer dereferences may occur.
> 
> To fix these possible bugs, buf is checked before being used.
> If it is NULL, -EINVAL is returned.
> 
> These bugs are found by a static analysis tool STCheck written by us.

Can we just get rid of the NULL testing?

Thanks.

-- 
tejun

      reply	other threads:[~2019-07-29 18:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24  2:22 Jia-Ju Bai
2019-07-29 18:51 ` Tejun Heo [this message]

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=20190729185133.GD569612@devbig004.ftw2.facebook.com \
    --to=tj@kernel.org \
    --cc=baijiaju1990@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.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

Powered by JetHome