Skip to content

Commit

Permalink
fs_lock:Check the nwaiter when deleting a bucket
Browse files Browse the repository at this point in the history
Summary:
  Fixed the problem of releasing the bucket prematurely in multi-threaded flock scenarios.

A thread setlk
B thread setlk_wait
A thread releases lock but fails to determine if nwaiter causes the bucket to be released prematurely
post B thread causes crash due to heap use after free

apache#13821

Signed-off-by: chenrun1 <[email protected]>
  • Loading branch information
crafcat7 committed Oct 5, 2024
1 parent e16c785 commit 338d07b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/vfs/fs_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static void file_lock_delete_bucket(FAR struct file_lock_bucket_s *bucket,
* released
*/

if (list_is_empty(&bucket->list))
if (list_is_empty(&bucket->list) && bucket->nwaiter == 0)
{
/* At this point, the file has no lock information context, so we can
* remove it from the hash table, and the return result is 0 or 1 means
Expand Down

0 comments on commit 338d07b

Please sign in to comment.