Skip to content

Commit

Permalink
Fix invalid pointer access in trace_dbuf.h
Browse files Browse the repository at this point in the history
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 openzfs#15333
  • Loading branch information
tuxoko authored and behlendorf committed Oct 3, 2023
1 parent a7b8885 commit c7ce610
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/os/linux/zfs/sys/trace_dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@

#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; \
Expand Down

0 comments on commit c7ce610

Please sign in to comment.