lkml.org 
[lkml]   [2021]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v6 23/34] dyndbg: fix NULL deref after deleting sites
Date
After `echo module main +D > control` zeros the site pointer for
main's callsites, `cat control` causes a NULL deref in
ddebug_site_get(). Fix this with:

- in vpr_infos, avoid dp->site->module, use dh->sites[dp->_index]
- qualify WARN_ONs that test against dp->site.

Also return dp->site, which may be null. This restores the
abbreviated control output of deleted sites, rather than pretending it
wasnt deleted.

Deleting sites isn't an important feature, and its current form will
be obsolete when the site pointer gets dropped. Its also pointless if
the site data is in compressed blocks. But its still worthwhile to
maintain !site robustness for a bit.

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

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 014e3a79d8e9..a7840584b402 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -154,8 +154,8 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp)

if (dp >= __start___dyndbg && dp < __stop___dyndbg) {

- v5pr_info("get: %s is builtin: %d %d %s:%s:%d\n",
- dp->site->modname, dp->_index, (int)(dp - dh),
+ v5pr_info("get: %s is builtin: %d %s:%s:%d\n",
+ dh->site[dp->_index].modname, dp->_index,
dh->site[dp->_index].filename,
dh->site[dp->_index].function, dp->lineno);

@@ -165,15 +165,16 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp)
dp->_index == (dp - __start___dyndbg) &&
dp->_index == (&__start___dyndbg_sites[dp->_index]
- &__start___dyndbg_sites[0])));
-
- WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site);
+ if (dp->site)
+ WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site);
} else {
v4pr_info("get: %s is loaded: %d %s:%s:%d\n",
- dp->site->modname, dp->_index,
+ dh->site[dp->_index].modname, dp->_index,
dh->site[dp->_index].filename,
dh->site[dp->_index].function, dp->lineno);
}
- WARN_ON(&dh->site[dp->_index] != dp->site);
+ if (dp->site)
+ WARN_ON(&dh->site[dp->_index] != dp->site);

return dp->site;
}
--
2.31.1
\
 
 \ /
  Last update: 2021-05-29 22:04    [W:0.104 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site