linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] tracing: fix potential null pointer dereference on rctr_end
Date: Thu, 27 Sep 2018 23:47:00 +0100	[thread overview]
Message-ID: <20180927224700.13739-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

Currently rctr_end may assigned null if strchr() fails leading to
a null pointer dereference in the following check on *(rctr_end + 1).
Fix this by also adding a null pointer check before the dereference.

Detected by CoverityScan, CID#1473700 ("Dereference null return value")

Fixes: 1cc33161a83d ("uprobes: Support SDT markers having reference count (semaphore)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 3a7c73c40007..c5514651e61f 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -477,7 +477,7 @@ static int create_trace_uprobe(int argc, char **argv)
 	rctr = strchr(arg, '(');
 	if (rctr) {
 		rctr_end = strchr(rctr, ')');
-		if (rctr > rctr_end || *(rctr_end + 1) != 0) {
+		if (!rctr_end || rctr > rctr_end || *(rctr_end + 1) != 0) {
 			ret = -EINVAL;
 			pr_info("Invalid reference counter offset.\n");
 			goto fail_address_parse;
-- 
2.17.1


             reply	other threads:[~2018-09-27 22:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27 22:47 Colin King [this message]
2019-03-28  0:37 ` [PATCH] tracing: fix potential null pointer dereference on rctr_end Steven Rostedt

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=20180927224700.13739-1-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).