Commit 2a1f40ad authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by Shuah Khan

rseq/selftests: Clarify rseq_prepare_unload() helper requirements

The rseq.h UAPI now documents that the rseq_cs field must be cleared
before reclaiming memory that contains the targeted struct rseq_cs, but
also that the rseq_cs field must be cleared before reclaiming memory of
the code pointed to by the rseq_cs start_ip and post_commit_offset
fields.

While we can expect that use of dlclose(3) will typically unmap
both struct rseq_cs and its associated code at once, nothing would
theoretically prevent a JIT from reclaiming the code without
reclaiming the struct rseq_cs, which would erroneously allow the
kernel to consider new code which is not a rseq critical section
as a rseq critical section following a code reclaim.
Suggested-by: default avatarFlorian Weimer <fw@deneb.enyo.de>
Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Florian Weimer <fw@deneb.enyo.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: "Paul E. McKenney" <paulmck@linux.ibm.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Paul Turner <pjt@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 8df34c56
......@@ -149,11 +149,13 @@ static inline void rseq_clear_rseq_cs(void)
/*
* rseq_prepare_unload() should be invoked by each thread executing a rseq
* critical section at least once between their last critical section and
* library unload of the library defining the rseq critical section
* (struct rseq_cs). This also applies to use of rseq in code generated by
* JIT: rseq_prepare_unload() should be invoked at least once by each
* thread executing a rseq critical section before reclaim of the memory
* holding the struct rseq_cs.
* library unload of the library defining the rseq critical section (struct
* rseq_cs) or the code referred to by the struct rseq_cs start_ip and
* post_commit_offset fields. This also applies to use of rseq in code
* generated by JIT: rseq_prepare_unload() should be invoked at least once by
* each thread executing a rseq critical section before reclaim of the memory
* holding the struct rseq_cs or reclaim of the code pointed to by struct
* rseq_cs start_ip and post_commit_offset fields.
*/
static inline void rseq_prepare_unload(void)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment