mirror of
https://github.com/torvalds/linux.git
synced 2026-11-24 07:22:34 +00:00
To avoid use-after-free(s), use a refcount to keep track of the usable references to any instantiated struct p9_req_t. This commit adds p9_req_put(), p9_req_get() and p9_req_try_get() as wrappers to kref_put(), kref_get() and kref_get_unless_zero(). These are used by the client and the transports to keep track of valid requests' references. p9_free_req() is added back and used as callback by kref_put(). Add SLAB_TYPESAFE_BY_RCU as it ensures that the memory freed by kmem_cache_free() will not be reused for another type until the rcu synchronisation period is over, so an address gotten under rcu read lock is safe to inc_ref() without corrupting random memory while the lock is held. Link: http://lkml.kernel.org/r/[email protected] Co-developed-by: Dominique Martinet <[email protected]> Signed-off-by: Tomas Bortoli <[email protected]> Reported-by: [email protected] Signed-off-by: Dominique Martinet <[email protected]>