From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#24659: 'mkdir' procedure is neither thread-safe nor safe (2.0.12) Date: Mon, 10 Oct 2016 18:39:47 +0200 Message-ID: <87pon8ma3w.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1476117824 5994 195.159.176.226 (10 Oct 2016 16:43:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Oct 2016 16:43:44 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: 24659@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Oct 10 18:43:40 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btdfi-0007jq-UH for guile-bugs@m.gmane.org; Mon, 10 Oct 2016 18:43:27 +0200 Original-Received: from localhost ([::1]:51442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btdfg-0006mi-Dw for guile-bugs@m.gmane.org; Mon, 10 Oct 2016 12:43:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btddS-00052O-20 for bug-guile@gnu.org; Mon, 10 Oct 2016 12:41:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btddO-0008Dy-Iy for bug-guile@gnu.org; Mon, 10 Oct 2016 12:41:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btddO-0008Dp-Ez for bug-guile@gnu.org; Mon, 10 Oct 2016 12:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1btddO-0004Iz-7X for bug-guile@gnu.org; Mon, 10 Oct 2016 12:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 10 Oct 2016 16:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24659 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.147611760616473 (code B ref -1); Mon, 10 Oct 2016 16:41:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Oct 2016 16:40:06 +0000 Original-Received: from localhost ([127.0.0.1]:51392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btdcT-0004Hd-Vf for submit@debbugs.gnu.org; Mon, 10 Oct 2016 12:40:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btdcR-0004H2-TK for submit@debbugs.gnu.org; Mon, 10 Oct 2016 12:40:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btdcL-0007rE-ST for submit@debbugs.gnu.org; Mon, 10 Oct 2016 12:39:58 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btdcL-0007qr-Pm for submit@debbugs.gnu.org; Mon, 10 Oct 2016 12:39:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btdcJ-00042E-B4 for bug-guile@gnu.org; Mon, 10 Oct 2016 12:39:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btdcE-0007oo-Td for bug-guile@gnu.org; Mon, 10 Oct 2016 12:39:54 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btdcE-0007oa-Qk for bug-guile@gnu.org; Mon, 10 Oct 2016 12:39:50 -0400 Original-Received: from pluto.bordeaux.inria.fr ([193.50.110.57]:40002 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1btdcD-0004V9-QR for bug-guile@gnu.org; Mon, 10 Oct 2016 12:39:50 -0400 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 19 =?UTF-8?Q?Vend=C3=A9miaire?= an 225 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-unknown-linux-gnu X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8421 Archived-At: Hello! When the optional =E2=80=98mode=E2=80=99 argument to the =E2=80=98mkdir=E2= =80=99 procedure is omitted, umask(2) is used to find out what the current mask is and to compute the mode argument to mkdir(2): --8<---------------cut here---------------start------------->8--- if (SCM_UNBNDP (mode)) { mask =3D umask (0); umask (mask); STRING_SYSCALL (path, c_path, rv =3D mkdir (c_path, 0777 ^ mask)); } --8<---------------cut here---------------end--------------->8--- The problem is that this changes the process=E2=80=99 umask globally for a = short duration, during which other threads will get 0 as the mask=E2=80=A6 Furthermore, AFAICS, the above logic is redundant with what the kernel does anyway. That is, in a single-threaded program, mask =3D umask (0); umask (mask); mkdir (file, 0777 ^ mask); is equivalent to: mkdir (file, 0777); Am I right that we should just remove these two =E2=80=98umask=E2=80=99 cal= ls? Ludo=E2=80=99. PS: This code has been there since 1996 or earlier.