From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 37E263858C00; Tue, 11 Apr 2023 14:18:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37E263858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681222726; bh=hszQK1Ilyq2KX1/OXAH2saFaLvCH44Ey00Q4WMm5D0o=; h=From:To:Subject:Date:From; b=qfoYGWnaCleaMuCHCn6yLphJATWaJaUZPAstIp9HZ41D5WdWdqAvHg1gLIysEN1VQ /SzrUewhTVPHsMQDOAXC+0pKLscjIsY0tkOo24lqrYjT3LhnFYl7/7/gkSYTXTTb7/ Q1J1T/QrfLTC0xWNMQpSD//Btx5XgbtuZYKTHIw4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/bz12683] arm: Fix Race conditions in pthread cancellation [BZ#12683] X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/bz12683 X-Git-Oldrev: 6b46ce14834b37a4557341d25bc267340fafc36d X-Git-Newrev: 072208a64fbf3aa01d2e46a8da89af94b0fd09f7 Message-Id: <20230411141846.37E263858C00@sourceware.org> Date: Tue, 11 Apr 2023 14:18:46 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=072208a64fbf3aa01d2e46a8da89af94b0fd09f7 commit 072208a64fbf3aa01d2e46a8da89af94b0fd09f7 Author: Adhemerval Zanella Date: Sun Apr 2 10:38:07 2023 -0300 arm: Fix Race conditions in pthread cancellation [BZ#12683] By adding the required syscall_cancel.S. Checked on arm-linux-gnueabihf. Diff: --- sysdeps/unix/sysv/linux/arm/syscall_cancel.S | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/sysdeps/unix/sysv/linux/arm/syscall_cancel.S b/sysdeps/unix/sysv/linux/arm/syscall_cancel.S new file mode 100644 index 0000000000..6b899306e3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/syscall_cancel.S @@ -0,0 +1,78 @@ +/* Cancellable syscall wrapper. Linux/arm version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* long int [r0] __syscall_cancel_arch (int *cancelhandling [r0], + long int nr [r1], + long int arg1 [r2], + long int arg2 [r3], + long int arg3 [SP], + long int arg4 [SP+4], + long int arg5 [SP+8], + long int arg6 [SP+12]) */ + + .syntax unified + +ENTRY (__syscall_cancel_arch) + .fnstart + mov ip, sp + stmfd sp!, {r4, r5, r6, r7, lr} + .save {r4, r5, r6, r7, lr} + + cfi_adjust_cfa_offset (20) + cfi_rel_offset (r4, 0) + cfi_rel_offset (r5, 4) + cfi_rel_offset (r6, 8) + cfi_rel_offset (r7, 12) + cfi_rel_offset (lr, 16) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ldr r0, [r0] + tst r0, #TCB_CANCELED_BITMASK + bne 1f + + /* Issue a 6 argument syscall, the nr [r1] being the syscall + number. */ + mov r7, r1 + mov r0, r2 + mov r1, r3 + ldmfd ip, {r2, r3, r4, r5, r6} + svc 0x0 + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + ldmfd sp!, {r4, r5, r6, r7, lr} + cfi_adjust_cfa_offset (-20) + cfi_restore (r4) + cfi_restore (r5) + cfi_restore (r6) + cfi_restore (r7) + cfi_restore (lr) + BX (lr) + +1: + ldmfd sp!, {r4, r5, r6, r7, lr} + b __syscall_do_cancel + .fnend +END (__syscall_cancel_arch)