Commits
Alexander Atanasov authored and Konstantin Khorenko committed 46ad581166d
ve/userns: remove all hashed entries before freeing user_namespace 548df8b4b57b (ve/userns: associate user_struct with the user_namespace, 2017-03-13) introduced dynamically allocated per-userns uid hastable instead of using a global static hash table. The problem with that allocate hashtable is that life cycle of the two objects is different - both structes use reference counts but they are counted separately. The contained objects (user_struct) are not referenced from user_namespace. The result of that is that on ve destroy last reference to user_namespace is dropped and it is freed - the allocated hash table is freed too. But user_structs that were hashed can still be used elsewhere (like on inodes), so when the reference to that structs is dropped (evict_inodes) they try to remove from the hash which was alrady freed. This results in writting a NULL to an already freed memory. But since this happens after some time that write usually corrupts some new allocation which results in a variety of crashes. To fix this remove all user_structs that are still in the hash when destroing user_namespace. The hash is used to lookup them but since the user_namespace is gone no further lookups are possible. https://jira.vzint.dev/browse/PSBM-150648 Signed-off-by: Alexander Atanasov <alexander.atanasov@virtuozzo.com> Feature: userns: make user related resources per userns