git: 623d96f4afb6 - stable/13 - Accessing the epoch structure should happen after the INIT_CHECK(). Else the epoch pointer may be NULL.

Hans Petter Selasky hselasky at FreeBSD.org
Wed Jun 2 12:24:47 UTC 2021


The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=623d96f4afb60eb0d6fcf5ba738d9880a3b10ca0

commit 623d96f4afb60eb0d6fcf5ba738d9880a3b10ca0
Author:     Hans Petter Selasky <hselasky at FreeBSD.org>
AuthorDate: 2021-05-21 09:06:27 +0000
Commit:     Hans Petter Selasky <hselasky at FreeBSD.org>
CommitDate: 2021-06-02 11:12:41 +0000

    Accessing the epoch structure should happen after the INIT_CHECK().
    Else the epoch pointer may be NULL.
    
    Sponsored by:   Mellanox Technologies // NVIDIA Networking
    
    (cherry picked from commit c82c200622b5380b8346de29879222538653f663)
---
 sys/kern/subr_epoch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c
index 210cf78d55f0..31b79513fdc2 100644
--- a/sys/kern/subr_epoch.c
+++ b/sys/kern/subr_epoch.c
@@ -442,13 +442,14 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et EPOCH_FILE_LINE)
 	struct thread *td;
 
 	MPASS(cold || epoch != NULL);
-	MPASS(epoch->e_flags & EPOCH_PREEMPT);
 	td = curthread;
 	MPASS((vm_offset_t)et >= td->td_kstack &&
 	    (vm_offset_t)et + sizeof(struct epoch_tracker) <=
 	    td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
 
 	INIT_CHECK(epoch);
+	MPASS(epoch->e_flags & EPOCH_PREEMPT);
+
 #ifdef EPOCH_TRACE
 	epoch_trace_enter(td, epoch, et, file, line);
 #endif


More information about the dev-commits-src-all mailing list