mips archs: fix runaway execution if start fn passed to clone returns
authorSegev Finer <segev208@gmail.com>
Wed, 15 Aug 2018 17:46:18 +0000 (20:46 +0300)
committerRich Felker <dalias@aerifal.cx>
Sat, 18 Aug 2018 15:22:28 +0000 (11:22 -0400)
Call SYS_exit on return from fn in __clone. This is the expected
behavior of this function. Without this the child task will crash on
return from fn, since it will return to nowhere.

src/thread/mips/clone.s
src/thread/mips64/clone.s
src/thread/mipsn32/clone.s

index 37dddf57ba9575c9e849b03ad195b0caea1ddf4a..30a0146bad8db6677546563aff3f073d397dab9e 100644 (file)
@@ -28,5 +28,8 @@ __clone:
        nop
 1:     lw $25, 0($sp)
        lw $4, 4($sp)
-       jr $25
+       jalr $25
        nop
+       move $4, $2
+       li $2, 4001
+       syscall
index 229d267721f9fff482ace9fad0fb4d116696201a..1b71e07c793c8a5c749abc21a8a91c4bddd68fcb 100644 (file)
@@ -26,5 +26,8 @@ __clone:
        nop
 1:     ld      $25, 0($sp)     # function pointer
        ld      $4, 8($sp)      # argument pointer
-       jr      $25             # call the user's function
+       jalr    $25             # call the user's function
        nop
+       move    $4, $2
+       li      $2, 5058
+       syscall
index 5103585227aa6824cf6d8203f6b3a57479daf143..ebf5dbeae2b519695164ad61c154b37b241da9ae 100644 (file)
@@ -26,5 +26,8 @@ __clone:
        nop
 1:     lw      $25, 0($sp)     # function pointer
        lw      $4, 4($sp)      # argument pointer
-       jr      $25             # call the user's function
+       jalr    $25             # call the user's function
        nop
+       move    $4, $2
+       li      $2, 6058
+       syscall