copperplate: Do not allow cancellation in hash_enter/search_probe
PATCH 1/1 copperplate: Do not allow cancellation in hash_enter/search_probe
It's not really safe to allow a potentially modifying operation to be canceled in the middle, just dropping the lock during rollback. Better defer cancellation until the lock is dropped.
Signed-off-by Jan Kiszka <[email protected]>
--- lib/boilerplate/hash.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
lib/boilerplate/hash.c +6 -4
@@ -277,6 +277,7 @@ int __hash_enter_probe(struct hash_table *t, {struct hash_bucket *bucket;struct hashobj *obj, *tmp; +struct service svc;int ret;holder_init (&newobj->link);
@@ -285,7 +286,7 @@ int __hash_enter_probe(struct hash_table *t,return ret; bucket =do_hash (t, key, len); -push_cleanup_lock (&t->lock); +CANCEL_DEFER (svc);write_lock (&t->lock);if (!list_empty (&bucket->obj_list)) {
@@ -311,7 +312,7 @@ int __hash_enter_probe(struct hash_table *t,list_append (&newobj->link, &bucket->obj_list); out:write_unlock (&t->lock); -pop_cleanup_lock (&t->lock); +CANCEL_RESTORE (svc);return ret; }
@@ -322,10 +323,11 @@ struct hashobj *hash_search_probe(struct hash_table *t, {struct hash_bucket *bucket;struct hashobj *obj, *tmp; +struct service svc; bucket =do_hash (t, key, len); -push_cleanup_lock (&t->lock); +CANCEL_DEFER (svc);write_lock (&t->lock);if (!list_empty (&bucket->obj_list)) {
@@ -345,7 +347,7 @@ struct hashobj *hash_search_probe(struct hash_table *t, obj =NULL ; out:write_unlock (&t->lock); -pop_cleanup_lock (&t->lock); +CANCEL_RESTORE (svc);return obj; }
Signature · 1 line
2.13.6