From nobody Tue Jul 4 18:18:29 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QwWJ55Fp9z4lj3b for ; Tue, 4 Jul 2023 18:18:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QwWJ50dTqz42VT for ; Tue, 4 Jul 2023 18:18:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688494709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DppLB6t8WxwsoniPWdIy9P7cQkQb65qqf6O/Sab+9QA=; b=HAnIw0Ulq9MKtHf2bGVnIRZXcT+WzSQK36vCv1+Hbz8EC5Yjzaoh8K3fsXtn78clTa6tE4 9xLWoW7Oea3MQxQa6miVehcVY/xjt/drx47hYvW3MOT4H8Eytfa4b9sITzD/cbTUVg00gp KumZIZNL1Zj7PiY+093q0tEKF4nPO0GWQIk7DIW5LEdnep0gY0fc9kpO1ynqrzTD2/23hP N9usdggUy0KhHWoCwd74i4WOsxa3XMJzACi8R3Cuuavjqj3hEJlFdFrAHQAvtdz5wUMb8Q mqCWVPFxbHwl7EVPUMpptnKvO5207XKfl9gnceUDDSwjaJon3l0xeEOWWEt5vw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688494709; a=rsa-sha256; cv=none; b=mzi1+Ay+c6rwSJ5nAFTHItEa/zdkD47kVkoOXSVnfUpKhG2UL0rjepXcvZyddmzGxBSyNL H3wO7bBBK7DTOAPPg3tZN3t1ZP4YHogSEbUcuNx479CS6zzjFBQMpPaV8grGA8T0Wpogpx RvG6IulahudhfOZ/AiRio33xRmj5ItP8QAANGXrai2heR0KPvz8RROCgZEp5IMUnfL3wMp ToTCOpqKagz9u0HeXoonI+x+KoyqNPU5IqrKzfOmhhVp/y3JMEvLvv3vfY0br0OZVIgyaB JsO0NXZmED/ajeYJNpG56s5o/UlAxWoPbjDFlQxxwuYbaH5CEx1sx7rwSwwfHw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QwWJ46pw2zjcL for ; Tue, 4 Jul 2023 18:18:28 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 364IISJf061026 for ; Tue, 4 Jul 2023 18:18:28 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 364IISBN061025 for bugs@FreeBSD.org; Tue, 4 Jul 2023 18:18:28 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 272367] openat(..., O_NONBLOCK | O_EXLOCK) may wrongly return EAGAIN Date: Tue, 04 Jul 2023 18:18:29 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: asomers@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.mimetype attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272367 Bug ID: 272367 Summary: openat(..., O_NONBLOCK | O_EXLOCK) may wrongly return EAGAIN Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: asomers@FreeBSD.org Attachment #243203 text/plain mime type: Created attachment 243203 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D243203&action= =3Dedit Reproduction script In a multithreaded program that involves forking, I sometimes see openat(..= ., O_NONBLOCK | O_EXLOCK) return EAGAIN for a file that should be unlocked.=20 ktrace clearly shows that only one thread access the file in question. That thread opens the file, does some I/O, then closes it. Immediately after closing it it tries to open again and that's when the openat fails. ktrace shows that no other thread tries to access the file in question. However, ktrace _also_ shows that another thread calls rfork while the first thread = has the file locked. flock(2) says that locks are associated with files, not file descriptors. = So if a process forks, the file should be unlocked whenever either the parent calls close() or the child calls fdcloseexec(). I can't understand how in neither case the file would fail to get unlocked, so I suspect a bug. The attached test case can reproduce the problem with either ZFS or tmpfs. Steps to Reproduce =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D cc -O2 -Wall -g -l pthread -o o_exlock o_exlock.c ./o_exlock /tmp/testfile where N is greater than 1. --=20 You are receiving this mail because: You are the assignee for the bug.=