All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Savkov <asavkov@redhat.com>
To: Anna Schumaker <Anna.Schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	trond.myklebust@primarydata.com, hch@lst.de,
	Artem Savkov <asavkov@redhat.com>
Subject: [PATCH v2] Fix NULL pointer dereference in bl_free_device().
Date: Tue, 19 Jul 2016 17:39:04 +0200	[thread overview]
Message-ID: <1468942744-10646-1-git-send-email-asavkov@redhat.com> (raw)
In-Reply-To: <f195fe6f-8e2c-b200-2b00-9cd84f29bfc5@Netapp.com>

When bl_parse_deviceid() fails in bl_alloc_deviceid_node() on
blkdev_get_by_*() step we get an pnfs_block_dev struct that is
uninitialized except for bdev field which is set to whatever error
blkdev_get_by_*() returns.  bl_free_device() then tries to call
blkdev_put() if bdev is not 0 resulting in a wrong pointer dereference.

Fixing this by making sure bdev is not an error code in bl_free_device().

Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
 fs/nfs/blocklayout/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
index 118252f..57cb800 100644
--- a/fs/nfs/blocklayout/dev.c
+++ b/fs/nfs/blocklayout/dev.c
@@ -33,7 +33,7 @@ bl_free_device(struct pnfs_block_dev *dev)
 				pr_err("failed to unregister PR key.\n");
 		}
 
-		if (dev->bdev)
+		if (!IS_ERR_OR_NULL(dev->bdev))
 			blkdev_put(dev->bdev, FMODE_READ | FMODE_WRITE);
 	}
 }
-- 
2.5.5

  reply	other threads:[~2016-07-19 15:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19 11:30 [PATCH] Fix NULL pointer dereference in bl_free_device() Artem Savkov
2016-07-19 13:57 ` Anna Schumaker
2016-07-19 15:21 ` Anna Schumaker
2016-07-19 15:39   ` Artem Savkov [this message]
2016-07-21  8:09     ` [PATCH v2] " Christoph Hellwig
2016-07-21 11:32       ` [PATCH v3] " Artem Savkov
2016-07-21 12:30         ` Benjamin Coddington

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=1468942744-10646-1-git-send-email-asavkov@redhat.com \
    --to=asavkov@redhat.com \
    --cc=Anna.Schumaker@netapp.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.