From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7BF98158086 for ; Fri, 19 Nov 2021 16:17:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9EC1FE0536; Fri, 19 Nov 2021 16:17:36 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D4C67E05AC for ; Fri, 19 Nov 2021 16:17:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4DDC13430E7 for ; Fri, 19 Nov 2021 16:17:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A5DBA1D4 for ; Fri, 19 Nov 2021 16:17:32 +0000 (UTC) From: "Mike Gilbert" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Gilbert" Message-ID: <1637338567.fe3e50025fee15d59c4956a39b675faf50555c46.floppym@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/estrip X-VCS-Directories: bin/ X-VCS-Committer: floppym X-VCS-Committer-Name: Mike Gilbert X-VCS-Revision: fe3e50025fee15d59c4956a39b675faf50555c46 X-VCS-Branch: master Date: Fri, 19 Nov 2021 16:17:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1a377b0c-bc33-4656-93a5-e561dc5c691a X-Archives-Hash: c07606b352b8cda289ab2720e8e6b551 commit: fe3e50025fee15d59c4956a39b675faf50555c46 Author: Mike Gilbert gentoo org> AuthorDate: Wed Nov 17 18:23:07 2021 +0000 Commit: Mike Gilbert gentoo org> CommitDate: Fri Nov 19 16:16:07 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fe3e5002 estrip: fix lockfile handling The previous code would wait for the first link to an inode to be processed, and would then allow multiple processes to process duplicate links to the same inode. This behavior leads to a race condition in save_elf_debug. The new code ensures that each inode is accessed by a single process at a time. Closes: https://bugs.gentoo.org/823798 Signed-off-by: Mike Gilbert gentoo.org> bin/estrip | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/estrip b/bin/estrip index 0ad79e2a3..599ca2ceb 100755 --- a/bin/estrip +++ b/bin/estrip @@ -270,7 +270,9 @@ save_elf_debug() { process_elf() { local x=$1 inode_link=$2 strip_flags=${*:3} local ed_noslash=${ED%/} - local already_stripped lockfile xt_data + local already_stripped xt_data + local lockfile=${inode_link}_lockfile + local locktries=100 __vecho " ${x:${#ed_noslash}}" @@ -279,13 +281,10 @@ process_elf() { # So, use a lockfile to prevent interference (easily observed with # dev-vcs/git which creates ~111 hardlinks to one file in # /usr/libexec/git-core). - lockfile=${inode_link}_lockfile - if ! ln "${inode_link}" "${lockfile}" 2>/dev/null ; then - while [[ -f ${lockfile} ]] ; do - sleep 1 - done - unset lockfile - fi + while ! ln "${inode_link}" "${lockfile}" 2>/dev/null; do + (( --locktries > 0 )) || die "failed to acquire lock '${lockfile}'" + sleep 1 + done [ -f "${inode_link}_stripped" ] && already_stripped=true || already_stripped=false