lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240617173426.4.Ie746acb6e0908f2f3328878e4aba7661d3daad7c@changeid>
Date: Mon, 17 Jun 2024 17:34:38 -0700
From: Douglas Anderson <dianders@...omium.org>
To: Daniel Thompson <daniel.thompson@...aro.org>
Cc: kgdb-bugreport@...ts.sourceforge.net,
	Douglas Anderson <dianders@...omium.org>,
	Christophe JAILLET <christophe.jaillet@...adoo.fr>,
	Jason Wessel <jason.wessel@...driver.com>,
	Thorsten Blum <thorsten.blum@...lux.com>,
	Yuran Pereira <yuran.pereira@...mail.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH 04/13] kdb: Drop "offset" and "name" args to kdbgetaddrarg()

Every caller to kdbgetaddrarg() didn't care about the "offset" and
"name" returned by the function. Some passed NULL and some passed the
address of a bogus local variable that was never looked at. Drop the
arguments.

Signed-off-by: Douglas Anderson <dianders@...omium.org>
---

 kernel/debug/kdb/kdb_bp.c      |  5 +----
 kernel/debug/kdb/kdb_bt.c      |  4 +---
 kernel/debug/kdb/kdb_main.c    | 37 ++++++++--------------------------
 kernel/debug/kdb/kdb_private.h |  4 ++--
 4 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c
index 372025cf1ca3..98659f7dd744 100644
--- a/kernel/debug/kdb/kdb_bp.c
+++ b/kernel/debug/kdb/kdb_bp.c
@@ -279,8 +279,6 @@ static int kdb_bp(int argc, const char **argv)
 	int i, bpno;
 	kdb_bp_t *bp, *bp_check;
 	int diag;
-	char *symname = NULL;
-	long offset = 0ul;
 	int nextarg;
 	kdb_bp_t template = {0};
 
@@ -299,8 +297,7 @@ static int kdb_bp(int argc, const char **argv)
 	}
 
 	nextarg = 1;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &template.bp_addr,
-			     &offset, &symname);
+	diag = kdbgetaddrarg(argc, argv, &nextarg, &template.bp_addr);
 	if (diag)
 		return diag;
 	if (!template.bp_addr)
diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
index 10b454554ab0..af86744c1e2f 100644
--- a/kernel/debug/kdb/kdb_bt.c
+++ b/kernel/debug/kdb/kdb_bt.c
@@ -130,7 +130,6 @@ kdb_bt(int argc, const char **argv)
 	int btaprompt = 1;
 	int nextarg;
 	unsigned long addr;
-	long offset;
 
 	/* Prompt after each proc in bta */
 	kdbgetintenv("BTAPROMPT", &btaprompt);
@@ -205,8 +204,7 @@ kdb_bt(int argc, const char **argv)
 	} else {
 		if (argc) {
 			nextarg = 1;
-			diag = kdbgetaddrarg(argc, argv, &nextarg, &addr,
-					     &offset, NULL);
+			diag = kdbgetaddrarg(argc, argv, &nextarg, &addr);
 			if (diag)
 				return diag;
 			kdb_show_stack(kdb_current_task, (void *)addr);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 88121334d189..74db5c0cc5ad 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -532,16 +532,12 @@ static int kdb_check_regs(void)
  *	regs	- Register state at time of KDB entry
  * Outputs:
  *	*value	- receives the value of the address-expression
- *	*offset - receives the offset specified, if any
- *	*name   - receives the symbol name, if any
  *	*nextarg - index to next unparsed argument in argv[]
  * Returns:
  *	zero is returned on success, a kdb diagnostic code is
  *      returned on error.
  */
-int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
-		  unsigned long *value,  long *offset,
-		  char **name)
+int kdbgetaddrarg(int argc, const char **argv, int *nextarg, unsigned long *value)
 {
 	unsigned long addr;
 	unsigned long off = 0;
@@ -615,12 +611,8 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
 
 	(*nextarg)++;
 
-	if (name)
-		*name = symname;
 	if (value)
 		*value = addr;
-	if (offset && name && *name)
-		*offset = addr - symtab.sym_start;
 
 	if ((*nextarg > argc)
 	 && (symbol == '\0'))
@@ -664,9 +656,6 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
 	if (!positive)
 		off = -off;
 
-	if (offset)
-		*offset += off;
-
 	if (value)
 		*value += off;
 
@@ -1116,14 +1105,10 @@ int kdb_parse(const char *cmdstr)
 	 */
 	{
 		unsigned long value;
-		char *name = NULL;
-		long offset;
 		int nextarg = 0;
 
-		if (kdbgetaddrarg(0, (const char **)argv, &nextarg,
-				  &value, &offset, &name)) {
+		if (kdbgetaddrarg(0, (const char **)argv, &nextarg, &value))
 			return KDB_NOTFOUND;
-		}
 
 		kdb_printf("%s = ", argv[0]);
 		kdb_symbol_print(value, NULL, KDB_SP_DEFAULT);
@@ -1593,7 +1578,6 @@ static int kdb_md(int argc, const char **argv)
 	char fmtchar, fmtstr[64];
 	unsigned long addr;
 	unsigned long word;
-	long offset = 0;
 	bool nosect = false;
 	bool symbolic = false;
 	bool valid = false;
@@ -1656,8 +1640,7 @@ static int kdb_md(int argc, const char **argv)
 	if (argc) {
 		unsigned long val;
 		int diag, nextarg = 1;
-		diag = kdbgetaddrarg(argc, argv, &nextarg, &addr,
-				     &offset, NULL);
+		diag = kdbgetaddrarg(argc, argv, &nextarg, &addr);
 		if (diag)
 			return diag;
 		if (argc > nextarg+2)
@@ -1793,7 +1776,6 @@ static int kdb_mm(int argc, const char **argv)
 {
 	int diag;
 	unsigned long addr;
-	long offset = 0;
 	unsigned long contents;
 	int nextarg;
 	int width;
@@ -1805,13 +1787,13 @@ static int kdb_mm(int argc, const char **argv)
 		return KDB_ARGCOUNT;
 
 	nextarg = 1;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr);
 	if (diag)
 		return diag;
 
 	if (nextarg > argc)
 		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &contents, NULL, NULL);
+	diag = kdbgetaddrarg(argc, argv, &nextarg, &contents);
 	if (diag)
 		return diag;
 
@@ -1837,7 +1819,6 @@ static int kdb_go(int argc, const char **argv)
 	unsigned long addr;
 	int diag;
 	int nextarg;
-	long offset;
 
 	if (raw_smp_processor_id() != kdb_initial_cpu) {
 		kdb_printf("go must execute on the entry cpu, "
@@ -1847,8 +1828,7 @@ static int kdb_go(int argc, const char **argv)
 	}
 	if (argc == 1) {
 		nextarg = 1;
-		diag = kdbgetaddrarg(argc, argv, &nextarg,
-				     &addr, &offset, NULL);
+		diag = kdbgetaddrarg(argc, argv, &nextarg, &addr);
 		if (diag)
 			return diag;
 	} else if (argc) {
@@ -2043,14 +2023,13 @@ static int kdb_ef(int argc, const char **argv)
 {
 	int diag;
 	unsigned long addr;
-	long offset;
 	int nextarg;
 
 	if (argc != 1)
 		return KDB_ARGCOUNT;
 
 	nextarg = 1;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr);
 	if (diag)
 		return diag;
 	show_regs((struct pt_regs *)addr);
@@ -2547,7 +2526,7 @@ static int kdb_per_cpu(int argc, const char **argv)
 	if (argc < 1 || argc > 3)
 		return KDB_ARGCOUNT;
 
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &symaddr, NULL, NULL);
+	diag = kdbgetaddrarg(argc, argv, &nextarg, &symaddr);
 	if (diag)
 		return diag;
 
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index 548fd4059bf9..1f685d9f16f9 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -105,8 +105,8 @@ extern int kdb_putword(unsigned long, unsigned long, size_t);
 extern int kdbgetularg(const char *, unsigned long *);
 extern int kdbgetu64arg(const char *, u64 *);
 extern char *kdbgetenv(const char *);
-extern int kdbgetaddrarg(int, const char **, int*, unsigned long *,
-			 long *, char **);
+extern int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
+			 unsigned long *value);
 extern int kdbgetsymval(const char *, kdb_symtab_t *);
 extern int kdbnearsym(unsigned long, kdb_symtab_t *);
 extern char *kdb_strdup(const char *str, gfp_t type);
-- 
2.45.2.627.g7a2c4fd464-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ