linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org
Cc: Jim Cromie <jim.cromie@gmail.com>, stable@vger.kernel.org
Subject: [RFC PATCH v2 01/19] dyndbg: fix use before null check
Date: Fri, 25 Dec 2020 13:19:26 -0700	[thread overview]
Message-ID: <20201225201944.3701590-2-jim.cromie@gmail.com> (raw)
In-Reply-To: <20201225201944.3701590-1-jim.cromie@gmail.com>

In commit a2d375eda771 ("dyndbg: refine export, rename to
dynamic_debug_exec_queries()"), a string is copied before checking it
isn't NULL.  Fix this, report a usage/interface error, and return the
proper error code.

Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()")
Cc: stable@vger.kernel.org
--
-v2 drop comment tweak, improve commit message

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index bd7b3aaa93c3..c70d6347afa2 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -561,9 +561,14 @@ static int ddebug_exec_queries(char *query, const char *modname)
 int dynamic_debug_exec_queries(const char *query, const char *modname)
 {
 	int rc;
-	char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
+	char *qry; /* writable copy of query */
 
-	if (!query)
+	if (!query) {
+		pr_err("non-null query/command string expected\n");
+		return -EINVAL;
+	}
+	qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
+	if (!qry)
 		return -ENOMEM;
 
 	rc = ddebug_exec_queries(qry, modname);
-- 
2.29.2


  reply	other threads:[~2020-12-25 20:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-25 20:19 [RFC PATCH v2 00/19] dynamic debug diet plan Jim Cromie
2020-12-25 20:19 ` Jim Cromie [this message]
2020-12-25 20:19 ` [RFC PATCH v2 02/19] dyndbg: split struct _ddebug, move display fields to new _ddebug_callsite Jim Cromie
2020-12-31  2:34   ` [dyndbg] e83b4a5011: leaking-addresses.proc.__dyndbg_callsites kernel test robot
2020-12-25 20:19 ` [RFC PATCH v2 03/19] dyndbg: refactor part of ddebug_change to ddebug_match_site Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 04/19] dyndbg: accept null site in ddebug_match_site Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 05/19] dyndbg: hoist ->site out of ddebug_match_site Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 06/19] dyndbg: accept null site in ddebug_change Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 07/19] dyndbg: accept null site in dynamic_emit_prefix Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 08/19] dyndbg: accept null site in ddebug_proc_show Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 09/19] dyndbg: optimize ddebug_emit_prefix Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 10/19] dyndbg: avoid calling dyndbg_emit_prefix when it has no work Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 11/19] dyndbg: refactor ddebug_alter_site out of ddebug_change Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 12/19] dyndbg: allow deleting site info via control interface Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 13/19] dyndbg: verify __dyndbg & __dyndbg_callsite invariant Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 14/19] dyndbg+module: expose ddebug_callsites to modules Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 15/19] dyndbg: add ddebug_site_get/put api with pass-thru impl Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 16/19] dyndbg: ddebug_site_get/put api commentary Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 17/19] dyndbg: rearrange struct ddebug_callsites Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 18/19] dyndbg: add module_index to struct _ddebug Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 19/19] dyndbg: try DEFINE_DYNAMIC_DEBUG_TABLE Jim Cromie
2020-12-29 18:56 ` [RFC PATCH v2 00/19] dynamic debug diet plan Joe Perches
2021-01-06 17:50   ` jim.cromie

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=20201225201944.3701590-2-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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).