Linux Device Mapper development
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Martin Wilck <mwilck@suse.com>
Subject: [PATCH 1/4] multipathd: avoid null pointer dereference in LOG_MSG
Date: Thu,  7 Feb 2019 17:52:59 -0600	[thread overview]
Message-ID: <20190207235302.21635-2-bmarzins@redhat.com> (raw)
In-Reply-To: <20190207235302.21635-1-bmarzins@redhat.com>

LOG_MSG() will dereference pp->mpp. Commit cb5ec664 added a call to
LOG_MSG() before the check for (!pp->mpp) in check_path.  This can cause
multipathd to crash.  LOG_MSG() should only be called if pp->mpp is set
and a checker is selected.

Also, checker_message() should fail to a generic message if c->cls isn't
set (which means that a checker hasn't been selected).

Fixes: cb5ec664 (multipathd: check_path: improve logging for "unusable
                 path" case)
Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/checkers.c | 2 +-
 multipathd/main.c       | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
index 848c4c3..ca95cae 100644
--- a/libmultipath/checkers.c
+++ b/libmultipath/checkers.c
@@ -295,7 +295,7 @@ const char *checker_message(const struct checker *c)
 {
 	int id;
 
-	if (!c || c->msgid < 0 ||
+	if (!c || !c->cls || c->msgid < 0 ||
 	    (c->msgid >= CHECKER_GENERIC_MSGTABLE_SIZE &&
 	     c->msgid < CHECKER_FIRST_MSGID))
 		goto bad_id;
diff --git a/multipathd/main.c b/multipathd/main.c
index 0e3ac2c..1caa40f 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2017,8 +2017,10 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 	}
 
 	if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) {
-		condlog(2, "%s: unusable path - checker failed", pp->dev);
-		LOG_MSG(2, verbosity, pp);
+		condlog(2, "%s: unusable path (%s) - checker failed", pp->dev,
+			checker_state_name(newstate));
+		if (pp->mpp && checker_selected(&pp->checker))
+			LOG_MSG(2, verbosity, pp);
 		conf = get_multipath_config();
 		pthread_cleanup_push(put_multipath_config, conf);
 		pathinfo(pp, conf, 0);
-- 
2.17.2

  reply	other threads:[~2019-02-07 23:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 23:52 [PATCH 0/4] multipath: fixes for invalid path device handling Benjamin Marzinski
2019-02-07 23:52 ` Benjamin Marzinski [this message]
2019-02-08  9:05   ` [PATCH 1/4] multipathd: avoid null pointer dereference in LOG_MSG Martin Wilck
2019-02-08 17:28     ` [PATCH 1/4] multipathd: avoid null pointer dereference in LOG_MSG\ Benjamin Marzinski
2019-02-07 23:53 ` [PATCH 2/4] multipath: blacklist zram devices Benjamin Marzinski
2019-02-08  9:08   ` Martin Wilck
2019-02-07 23:53 ` [PATCH 3/4] multipathd: fix pp->initialized state ping-ponging Benjamin Marzinski
2019-02-08  9:21   ` Martin Wilck
2019-02-07 23:53 ` [PATCH 4/4] multipathd: don't resend change events for unknown devices Benjamin Marzinski
2019-02-08  9:21   ` Martin Wilck

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=20190207235302.21635-2-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.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