public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Colin King <colin.king@canonical.com>
Cc: Dave Chinner <david@fromorbit.com>,
	xfs@oss.sgi.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xfs: fix null pointer dereference when mapping is NULL
Date: Thu, 3 Sep 2015 06:45:37 -0400	[thread overview]
Message-ID: <20150903104537.GA46225@bfoster.bfoster> (raw)
In-Reply-To: <1441274260-10120-1-git-send-email-colin.king@canonical.com>

On Thu, Sep 03, 2015 at 10:57:40AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> xfs_vm_set_page_dirty checks to see if mapping is NULL however
> before this unlikely check it already dereferenced mapping when
> initializing inode. Move the inode initialization after the mapping
> null check to avoid a potential null pointer dereference.
> 
> Fixes: 22e757a49cf0 ("xfs: don't dirty buffers beyond EOF")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_aops.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index c77499b..d15ae85 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -1935,7 +1935,7 @@ xfs_vm_set_page_dirty(
>  	struct page		*page)
>  {
>  	struct address_space	*mapping = page->mapping;
> -	struct inode		*inode = mapping->host;
> +	struct inode		*inode;
>  	loff_t			end_offset;
>  	loff_t			offset;
>  	int			newly_dirty;
> @@ -1944,6 +1944,7 @@ xfs_vm_set_page_dirty(
>  	if (unlikely(!mapping))
>  		return !TestSetPageDirty(page);
>  
> +	inode = mapping->host;
>  	end_offset = i_size_read(inode);
>  	offset = page_offset(page);
>  
> -- 
> 2.5.0
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-09-03 10:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03  9:57 [PATCH] xfs: fix null pointer dereference when mapping is NULL Colin King
2015-09-03 10:45 ` Brian Foster [this message]
2015-09-03 13:45   ` Eric Sandeen

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=20150903104537.GA46225@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=colin.king@canonical.com \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs@oss.sgi.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