From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9760 invoked from network); 9 Oct 2020 20:25:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Oct 2020 20:25:16 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1602275116; b=HzyaC6VZChtbrqaxhx4ZYqmijC118pseFkQ58uL9O7Hw9VqvFFkbvU2+TQsqV4y8n2/JmPIs3T ldD7MU4/TzSORD4c8/4L/07MfkUR/vWFQrqU/LrLpppP5c2uzQp6Ak36knoSaRxqYXhH8hVbFm xnS21nMRpgJ8bxOU4eP4f8HrN/zohLYTdqx0rL8LPEPBSZosOlSF5478xYmb9/rOQ6z7FQAQzB 8i+pohHtSBz9+KTh23Ee33Wp4E5BDgR71krikg1mSRgo9gbQCj9Y8KZnZ1tuXDGNMQJV1CFaqI +36evPwOwkex/sbWlVAWmo9c5i7P8YkSrKMx6brFlYJ60Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f175.google.com) smtp.remote-ip=209.85.167.175; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1602275116; bh=TCJwd/qPRiywRiW17+cthhjOyHppuJ6Sznvc/52UKb8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=qM5C5uOv7C5lr4NmIt3XkZzgSTYHdTn1Vo0UyL/a56yOCwrK/Od3ujfDChhr62LqldthMflJE/ vWvfpIfQIWkWRJoUB2svYlHuX3TBuqrdUJauiMhB3fcbirJ446r25npCfoOQnzhVidockCk30+ SVZWNPbZ8KxZ6x50zJWH4cfkbMNEZ5X0TAcc93U8h94zem1OHEqkPDdQt+7yvZseZb6XGCkj6l 9BZcILTLguBgVpjKNW7mANKgOxbZ7FCHkeUP/oQ7BBfOZDZAwPEUxEQ0KvAgnSTLDI/H/d7kqX lZQwy7XMu3bqTCw8BOwuIH6akaceuYQirSrWL0XGvLyYFA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=IGT/h7ob03A1TtaObAsvHxdwJG5rf4W3YEZu9GCSjos=; b=pkhgnqRH6Yl9uKatcqiaoS0mnf +bETHHT/Us+08V10125cKayF6tJaLD1+pZDbzJg/e3GVvQlwoAu7xnrrbxmuqxg4u8X5SP0Lo5x8a ubCTw1/LUiKYsfRNyhyiUQl/JUkomdXbnYCLCHLeoCsfbtGluw3BMVK2r+EikPdnigVr03JbjHW0G QszCqxdZs/RiKplb2mqQtcHfS3jPsJZ2capHwzMN6RRP7bWIQl2IwaNIUQmvLVfxupNXZcJ+/133L KHqxd6muWXTapHIDUvfuw4bACKzoKPJCiDj1Kx0DiWVGU6Gt/4RL64/5Q7JOTfC1JzemRcABbMTw8 1mHCfHxw==; Received: from authenticated user by zero.zsh.org with local id 1kQyx1-000HSm-L9; Fri, 09 Oct 2020 20:25:15 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f175.google.com) smtp.remote-ip=209.85.167.175; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f175.google.com ([209.85.167.175]:44284) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kQywh-000HIj-7K; Fri, 09 Oct 2020 20:24:56 +0000 Received: by mail-oi1-f175.google.com with SMTP id x62so11452438oix.11 for ; Fri, 09 Oct 2020 13:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=IGT/h7ob03A1TtaObAsvHxdwJG5rf4W3YEZu9GCSjos=; b=cZd+A9/jV7dx8cxY7liSS1t6t1hm1kHJpjZA9Ck5TuTpM2QKmLCFIiWhOA0vL6tKDj pC3i1sEnwqlYqBQTe/YnGW3wpYqppUaFA8xiJ6+3zVZ6HU9aHKQvkaPKNCAxIlAfEeY7 4hrxUMb7eJXqs0PdtkSN1DDukpFWyIykefQ2dH/fuuuzxKu8qEmUokibXhi84/lz94F9 GBbR9S4omwlspiOc+gIToQafcdbYqt0mg5N6vglQuLANnUkR7In3vAU9tA47C+EDvktl J5Tn/dMCUfpCVWzcFGxnHi9ZIPKRBD2SS4UZOQV7eiTslA2u+QGJGauyY8Wl/HzmncjG gutg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=IGT/h7ob03A1TtaObAsvHxdwJG5rf4W3YEZu9GCSjos=; b=DAz9nSKpOcld7uJYtIjCWqY35cz9lqbTkKDvnCl2+6R05nQ3wobZ+UzgKxtuyjiNCs OdJ1UCmaZOPd6yopOVNAxXJm3kFxWGoeKPh8sz2+Bdq+bPWrcN8NPxLniaoD7zsPt+D3 WXsR3WUAjl+8mAchdLRbptklANdQ3QLYlg9wnqskPYxHoFLJOBWwdARlvN9i65/Fp0iw PEO3WX7J/4aMsSidJ3ei2OTWmYCYI2eKcsg7oNWBxWoQy+F98CdV0Vkk3ZZ8DNW6QRMO ymMEMEZvecyTkzbCS7UMjtFgVIgF3Vgx0LLEpye8hPGRfS8LSOuX3cdW8CO6VHkOeW4f qdOw== X-Gm-Message-State: AOAM531sJjKIfXwu/aIOVMhfM9tUSJUTWqEvHwjmXAh7zL8LA3Rp9DRO ucTxEmsHBbulc5s+cVJeRs43QjjY7kNeCB4++kjkfuTNpjFLlQ== X-Google-Smtp-Source: ABdhPJxD6SRLuenLqGusfwPACVD9HGqDgmTm3X605QomBErILVLmE+FshcKZsyF5O5OEsDT+AYPi4c6VF0ZvM8X84As= X-Received: by 2002:aca:4f4e:: with SMTP id d75mr3757103oib.132.1602275093198; Fri, 09 Oct 2020 13:24:53 -0700 (PDT) MIME-Version: 1.0 References: <20201009200737.GA78914@CptOrmolo.darkstar> In-Reply-To: <20201009200737.GA78914@CptOrmolo.darkstar> From: Bart Schaefer Date: Fri, 9 Oct 2020 13:24:42 -0700 Message-ID: Subject: Re: [patch] Avoid race in zf_mkdir To: "zsh-workers@zsh.org" Content-Type: multipart/alternative; boundary="000000000000c34c0705b142bd9c" X-Seq: 47437 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --000000000000c34c0705b142bd9c Content-Type: text/plain; charset="UTF-8" On Fri, Oct 9, 2020 at 1:08 PM Matthew Martin wrote: > A user reported in #zsh they were seeing sporadic zf_mkdir errors when > concurrently creating the same directory. Move the stat ISDIR check to > after the mkdir call to avoid the race. > Er, sorry, this doesn't actually avoid the race, it just prevents the error message from being shown by whichever shell loses the race. I'm not sure that's really desirable? Sometimes you might want to know that the directory was NOT created BY the current shell? On the flip side in the original code we skip the mkdir entirely if the directory already exists, so perhaps this is close enough. In neither variation are we checking that the existing directory actually has the requested mode. --000000000000c34c0705b142bd9c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Oct 9, 2020 at 1:08 PM Matthew Ma= rtin <phy1729@gmail.com> wro= te:
A user reported in #zsh they were seeing sporadic zf_mkdir e= rrors when
concurrently creating the same directory. Move the stat ISDIR check to
after the mkdir call to avoid the race.

Er, sorry, this doesn't actually avoid the race, it just prevents the = error message from being shown by whichever shell loses the race.

I'm not sure that's really desirable?=C2=A0 Sometim= es you might want to know that the directory was NOT created BY the current= shell?

On the flip side in the original code we skip the mkdir entirel= y if the directory already exists, so perhaps this is close enough.

In neither va= riation are we checking that the existing directory actually has the reques= ted mode.

--000000000000c34c0705b142bd9c--