[PATCH] afs: Fix crash when mounting dynroot with tracing enabled

Marc Dionne marc.dionne at auristor.com
Thu Mar 24 04:06:30 PDT 2022


If the mount is for a dynamic root, as->volume and as->cell are left
NULL by afs_alloc_sbi, causing a crash if afs_get_tree tracing is
enabled.

Use made up values in that case such that we still get a trace entry,
such as:

    .....   146.189816: afs_get_tree: --- MOUNT dynroot:dynroot 0

Fixes: 80548b03991f ("afs: Add more tracepoints")
Signed-off-by: Marc Dionne <marc.dionne at auristor.com>
---
 include/trace/events/afs.h | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h
index 499f5fabd20f..1f938c7ad823 100644
--- a/include/trace/events/afs.h
+++ b/include/trace/events/afs.h
@@ -1372,13 +1372,22 @@ TRACE_EVENT(afs_get_tree,
 
 	    TP_fast_assign(
 		    int __len;
-		    __entry->vid = volume->vid;
-		    __len = min_t(int, cell->name_len, 23);
-		    memcpy(__entry->cell, cell->name, __len);
-		    __entry->cell[__len] = 0;
-		    __len = min_t(int, volume->name_len, 23);
-		    memcpy(__entry->volume, volume->name, __len);
-		    __entry->volume[__len] = 0;
+		    if (volume) {
+			    __entry->vid = volume->vid;
+			    __len = min_t(int, volume->name_len, 23);
+			    memcpy(__entry->volume, volume->name, __len);
+			    __entry->volume[__len] = 0;
+		    } else {
+			    __entry->vid = 0;
+			    strcpy(__entry->volume, "dynroot");
+		    }
+		    if (cell) {
+			    __len = min_t(int, cell->name_len, 23);
+			    memcpy(__entry->cell, cell->name, __len);
+			    __entry->cell[__len] = 0;
+		    } else {
+			    strcpy(__entry->cell, "dynroot");
+		    }
 			   ),
 
 	    TP_printk("--- MOUNT %s:%s %llx",
-- 
2.35.1




More information about the linux-afs mailing list