diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
index f3985e7f71..67a30405a2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/clone.S
+++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
@@ -23,6 +23,9 @@
 #include <bits/errno.h>
 #include <asm-syntax.h>
 
+/* Neither <sched.h> nor <linux/sched.h> are usable in assembler files.  */
+#define CLONE_VM 0x00000100
+
 /* The userland implementation is:
    int clone (int (*fn)(void *arg), void *child_stack, int flags,
 	      void *arg, pid_t *parent_tid, void *tls, pid_t *child_tid);
@@ -94,6 +97,15 @@ L(thread_start):
 	   the outermost frame obviously.  */
 	xorl	%ebp, %ebp
 
+	/* If a fork-style clone is performed, reset the TID in the TCB.
+	   Without CLONE_VM, the TID is not shared and safe to re-use.  */
+	test	$CLONE_VM, %edi
+	jnz	1f
+	movl	$SYS_ify(gettid), %eax
+	syscall
+	movl	%eax, %fs:TID
+1:
+
 	/* Set up arguments for the function call.  */
 	popq	%rax		/* Function to call.  */
 	popq	%rdi		/* Argument.  */
