Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0543-erts-Fix-ets-table-name-lookup-race.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0543-erts-Fix-ets-table-name-lookup-race.patch of Package erlang
From ebc1c32840a7adb09b944b1d01fb4b8591638adf Mon Sep 17 00:00:00 2001 From: Sverker Eriksson <sverker@erlang.org> Date: Wed, 21 Sep 2022 18:18:27 +0200 Subject: [PATCH 3/5] erts: Fix ets table name lookup race A named table op could theoretically be observed after the table was renamed. --- erts/emulator/beam/erl_db.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/erts/emulator/beam/erl_db.c b/erts/emulator/beam/erl_db.c index 456770041a..c71c951785 100644 --- a/erts/emulator/beam/erl_db.c +++ b/erts/emulator/beam/erl_db.c @@ -763,10 +763,11 @@ DbTable* db_get_table_aux(Process *p, Eterm id, int what, db_lock_kind_t kind, - int meta_already_locked, + int name_already_locked, Uint* freason_p) { DbTable *tb; + erts_rwmtx_t *name_lck = NULL; /* * IMPORTANT: Only non-dirty scheduler threads are allowed @@ -777,19 +778,19 @@ DbTable* db_get_table_aux(Process *p, ASSERT((what == DB_READ_TBL_STRUCT) == (kind == LCK_NOLOCK_ACCESS)); if (META_DB_LOCK_FREE()) - meta_already_locked = 1; + name_already_locked = 1; if (is_not_atom(id)) { tb = tid2tab(id, &p->fvalue); } else { - erts_rwmtx_t *mtl; - struct meta_name_tab_entry* bucket = meta_name_tab_bucket(id,&mtl); - if (!meta_already_locked) - erts_rwmtx_rlock(mtl); + struct meta_name_tab_entry* bucket = meta_name_tab_bucket(id,&name_lck); + if (!name_already_locked) + erts_rwmtx_rlock(name_lck); else { ERTS_LC_ASSERT(META_DB_LOCK_FREE() - || erts_lc_rwmtx_is_rlocked(mtl) - || erts_lc_rwmtx_is_rwlocked(mtl)); + || erts_lc_rwmtx_is_rlocked(name_lck) + || erts_lc_rwmtx_is_rwlocked(name_lck)); + name_lck = NULL; } tb = NULL; if (bucket->pu.tb != NULL) { @@ -808,19 +809,25 @@ DbTable* db_get_table_aux(Process *p, } } } - if (!meta_already_locked) - erts_rwmtx_runlock(mtl); if (tb == NULL) { + if (name_lck) + erts_rwmtx_runlock(name_lck); p->fvalue = EXI_ID; } } if (tb) { - if (what == DB_READ_TBL_STRUCT) + if (what == DB_READ_TBL_STRUCT) { + if (name_lck) + erts_rwmtx_runlock(name_lck); return tb; + } db_lock(tb, kind); + if (name_lck) + erts_rwmtx_runlock(name_lck); + #ifdef ETS_DBG_FORCE_TRAP /* * The ets_SUITE uses this to verify that all table lookups calls -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor