Skip to content

Commit a24cc6c

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
futex: Initialize futex_phash_new during fork().
During a hash resize operation the new private hash is stored in mm_struct::futex_phash_new if the current hash can not be immediately replaced. The new hash must not be copied during fork() into the new task. Doing so will lead to a double-free of the memory by the two tasks. Initialize the mm_struct::futex_phash_new during fork(). Closes: https://lore.kernel.org/all/[email protected]/ Fixes: bd54df5 ("futex: Allow to resize the private local hash") Reported-by: Calvin Owens <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Calvin Owens <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 86731a2 commit a24cc6c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/linux/futex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void futex_hash_free(struct mm_struct *mm);
8989
static inline void futex_mm_init(struct mm_struct *mm)
9090
{
9191
RCU_INIT_POINTER(mm->futex_phash, NULL);
92+
mm->futex_phash_new = NULL;
9293
mutex_init(&mm->futex_hash_lock);
9394
}
9495

0 commit comments

Comments
 (0)