mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>, mark@fasheh.com, jlbec@evilplan.org
Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc()
Date: Fri, 26 Jul 2019 17:39:37 +0800	[thread overview]
Message-ID: <3db34626-a87f-9de8-6f9c-e4a35f863cd6@linux.alibaba.com> (raw)
In-Reply-To: <20190726033717.32359-1-baijiaju1990@gmail.com>



On 19/7/26 11:37, Jia-Ju Bai wrote:
> In ocfs2_info_scan_inode_alloc(), there is an if statement on line 283
> to check whether inode_alloc is NULL:
>     if (inode_alloc)
> 
> When inode_alloc is NULL, it is used on line 287:
>     ocfs2_inode_lock(inode_alloc, &bh, 0);
>         ocfs2_inode_lock_full_nested(inode, ...)
>             struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
> 
> Thus, a possible null-pointer dereference may occur.
> 
> To fix this bug, inode_alloc is checked on line 286.
> 
> This bug is found by a static analysis tool STCheck written by us.       
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>

Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> ---
>  fs/ocfs2/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
> index d6f7b299eb23..efeea208fdeb 100644
> --- a/fs/ocfs2/ioctl.c
> +++ b/fs/ocfs2/ioctl.c
> @@ -283,7 +283,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb,
>  	if (inode_alloc)
>  		inode_lock(inode_alloc);
>  
> -	if (o2info_coherent(&fi->ifi_req)) {
> +	if (inode_alloc && o2info_coherent(&fi->ifi_req)) {
>  		status = ocfs2_inode_lock(inode_alloc, &bh, 0);
>  		if (status < 0) {
>  			mlog_errno(status);
> 

      reply	other threads:[~2019-07-26  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  3:37 Jia-Ju Bai
2019-07-26  9:39 ` Joseph Qi [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=3db34626-a87f-9de8-6f9c-e4a35f863cd6@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=baijiaju1990@gmail.com \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /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