Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Oct 2020 16:42:53 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r367059 - head/sys/ddb
Message-ID:  <202010261642.09QGgr2R087489@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Mon Oct 26 16:42:53 2020
New Revision: 367059
URL: https://svnweb.freebsd.org/changeset/base/367059

Log:
  db_search_symbol: prevent pollution from bogus symbols
  
  The kernel will never map the first page, so any symbols in that
  range cannot refer to addresses.  Some third-party assembly files
  define internal constants which appear in their symbol table.
  Avoiding the lookup for those symbols avoids replacing small offsets
  with those symbols during disassembly.
  
  Reported by:	Anton Rang <rang%acm.org>
  Reviewed by:	Anton Rang <rang%acm.org>, markj
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D26895

Modified:
  head/sys/ddb/db_sym.c

Modified: head/sys/ddb/db_sym.c
==============================================================================
--- head/sys/ddb/db_sym.c	Mon Oct 26 13:24:20 2020	(r367058)
+++ head/sys/ddb/db_sym.c	Mon Oct 26 16:42:53 2020	(r367059)
@@ -371,8 +371,21 @@ db_search_symbol(db_addr_t val, db_strategy_t strategy
 	unsigned int	diff;
 	size_t		newdiff;
 	int		i;
-	c_db_sym_t	ret = C_DB_SYM_NULL, sym;
+	c_db_sym_t	ret, sym;
 
+	/*
+	 * The kernel will never map the first page, so any symbols in that
+	 * range cannot refer to addresses.  Some third-party assembly files
+	 * define internal constants which appear in their symbol table.
+	 * Avoiding the lookup for those symbols avoids replacing small offsets
+	 * with those symbols during disassembly.
+	 */
+	if (val < PAGE_SIZE) {
+		*offp = 0;
+		return (C_DB_SYM_NULL);
+	}
+
+	ret = C_DB_SYM_NULL;
 	newdiff = diff = val;
 	for (i = 0; i < db_nsymtab; i++) {
 	    sym = X_db_search_symbol(&db_symtabs[i], val, strategy, &newdiff);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010261642.09QGgr2R087489>