]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix invalid pointer access in trace_dbuf.h
authorChunwei Chen <tuxoko@gmail.com>
Mon, 2 Oct 2023 23:58:01 +0000 (16:58 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2023 23:58:01 +0000 (16:58 -0700)
In dnode_destroy, dn_objset is invalidated. However, it will later call
into dbuf_destroy, in which DTRACE_SET_STATE will try to access spa_name
via dn_objset causing illegal pointer access.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #15333

include/os/linux/zfs/sys/trace_dbuf.h

index 11d25be35bc4bcb946826e84ec45b215799d66e4..0f6a98b47d609a1ccc1bf65458e43f8112a54c0b 100644 (file)
 
 #define        DBUF_TP_FAST_ASSIGN                                             \
        if (db != NULL) {                                               \
-               __assign_str(os_spa,                                    \
-               spa_name(DB_DNODE(db)->dn_objset->os_spa));             \
+               if (POINTER_IS_VALID(DB_DNODE(db)->dn_objset)) {        \
+                       __assign_str(os_spa,                            \
+                       spa_name(DB_DNODE(db)->dn_objset->os_spa));     \
+               } else {                                                \
+                       __assign_str(os_spa, "NULL");                   \
+               }                                                       \
                                                                        \
                __entry->ds_object = db->db_objset->os_dsl_dataset ?    \
                db->db_objset->os_dsl_dataset->ds_object : 0;           \