qemu-irix/docs/devel
Paolo Bonzini 3568e11940 memory: avoid "resurrection" of dead FlatViews
It's possible for address_space_get_flatview() as it currently stands
to cause a use-after-free for the returned FlatView, if the reference
count is incremented after the FlatView has been replaced by a writer:

   thread 1             thread 2             RCU thread
  -------------------------------------------------------------
   rcu_read_lock
   read as->current_map
                        set as->current_map
                        flatview_unref
                           '--> call_rcu
   flatview_ref
     [ref=1]
   rcu_read_unlock
                                             flatview_destroy
   <badness>

Since FlatViews are not updated very often, we can just detect the
situation using a new atomic op atomic_fetch_inc_nonzero, similar to
Linux's atomic_inc_not_zero, which performs the refcount increment only if
it hasn't already hit zero.  This is similar to Linux commit de09a9771a53
("CRED: Fix get_task_cred() and task_state() to not resurrect dead
credentials", 2010-07-29).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 447b0d0b9e)
 Conflicts:
	docs/devel/atomics.txt
* drop documentation ref to atomic_fetch_xor
* prereq for 166206845f
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2017-12-04 22:03:33 -06:00
..
atomics.txt memory: avoid "resurrection" of dead FlatViews 2017-12-04 22:03:33 -06:00
blkdebug.txt
blkverify.txt
build-system.txt
lockcnt.txt docs: fix broken paths to docs/devel/atomics.txt 2017-07-31 13:12:47 +03:00
memory.txt
migration.txt
multi-thread-tcg.txt
multiple-iothreads.txt
qapi-code-gen.txt qapi: Introduce a first class 'null' type 2017-07-24 13:35:11 +02:00
rcu.txt
tracing.txt trace: add trace_event_get_state_backends() 2017-08-01 12:13:07 +01:00
virtio-migration.txt
writing-qmp-commands.txt docs: fix broken paths to docs/devel/qapi-code-gen.txt 2017-07-31 13:12:41 +03:00