Skip to contentSkip to conversation

cobalt/debug: Detect DSOs via presence of vm_file

PATCH New Jan Kiszka 1 participant 1 message Jan 3, 2022

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH v2 1/1 cobalt/debug: Detect DSOs via presence of vm_file

From: Jan Kiszka <[email protected]>

VM_DENYWRITE was removed in 5.15, so we need a different criteria. Presence of a file-backing seems to be a good one.

---

Changes in v2:
- fixed inverted logic
- adjusted description

 kernel/cobalt/debug.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
kernel/cobalt/debug.c +5 -7
index e8458855a6..cde0c17abe 100644
@@ -250,13 +250,12 @@ void xndebug_trace_relax(int nr, unsigned long *backtrace,
 			continue;
 
 		/*
-		 * Hack. Unlike DSOs, executables and interpreters
-		 * (e.g. dynamic linkers) are protected against write
-		 * attempts. Use this to determine when $pc should be
-		 * fixed up by subtracting the mapping base address in
-		 * the DSO case.
+		 * Interpreter-generated executable mappings are not
+		 * file-backed. Use this to determine when $pc should be fixed
+		 * up by subtracting the mapping base address in the DSO case.
 		 */
-		if (!(vma->vm_flags & VM_DENYWRITE))
+		file = vma->vm_file;
+		if (file != NULL)
 			pc -= vma->vm_start;
 
 		spot.backtrace[depth].pc = pc;
@@ -266,7 +265,6 @@ void xndebug_trace_relax(int nr, unsigned long *backtrace,
 		 * record the PC value, which may still give some hint
 		 * downstream.
 		 */
-		file = vma->vm_file;
 		if (file == NULL)
 			goto next_frame;
 
Signature · 1 line
2.31.1