linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dyndbg: fix use before null check
@ 2020-11-23 18:43 Jim Cromie
  2020-12-09 14:54 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Cromie @ 2020-11-23 18:43 UTC (permalink / raw)
  To: Jason Baron, Greg Kroah-Hartman, Jim Cromie, linux-kernel; +Cc: stable

commit a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()")

Above commit copies a string before checking for null pointer, fix
this, and add a pr_err.  Also trim comment, and add return val info.

Fixes: a2d375eda771
Cc: stable@vger.kernel.org
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index bd7b3aaa93c3..711a9def8c83 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -553,17 +553,23 @@ static int ddebug_exec_queries(char *query, const char *modname)
  * @query: query-string described in admin-guide/dynamic-debug-howto
  * @modname: string containing module name, usually &module.mod_name
  *
- * This uses the >/proc/dynamic_debug/control reader, allowing module
- * authors to modify their dynamic-debug callsites. The modname is
- * canonically struct module.mod_name, but can also be null or a
- * module-wildcard, for example: "drm*".
+ * This uses the >control reader, allowing module authors to modify
+ * their dynamic-debug callsites. The modname is canonically struct
+ * module.mod_name, but can also be null or a module-wildcard, for
+ * example: "drm*".
+ * Returns <0 on error, >=0 for callsites changed
  */
 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.28.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dyndbg: fix use before null check
  2020-11-23 18:43 [PATCH] dyndbg: fix use before null check Jim Cromie
@ 2020-12-09 14:54 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-09 14:54 UTC (permalink / raw)
  To: Jim Cromie; +Cc: Jason Baron, linux-kernel, stable

On Mon, Nov 23, 2020 at 11:43:34AM -0700, Jim Cromie wrote:
> commit a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()")
> 
> Above commit copies a string before checking for null pointer, fix
> this, and add a pr_err.  Also trim comment, and add return val info.

The way you list the above commit is very odd, and hard to read and
understand.  How about something like:

	In commit a2d375eda771 ("dyndbg: refine export, rename to
	dynamic_debug_exec_queries()"), a string is copied before
	checking....


Also, when you say "also" in a patch, that is a HUGE flag that the
commit needs to be broken up into multiple patches.  Put the bugfix
first, and then fix up the comment later, if it is not being changed for
this fix.

Also:

> Fixes: a2d375eda771

You need the full information here, please write:
	Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()")


Can you fix all of that up and resend?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-09 14:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23 18:43 [PATCH] dyndbg: fix use before null check Jim Cromie
2020-12-09 14:54 ` Greg Kroah-Hartman

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).