From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 22582385841E; Wed, 13 Mar 2024 10:43:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22582385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710326585; bh=Ge+VHD1RHJP4NlTGnqcJKghFbNTpFOQiYIm4nf31g1E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kYbQkZs3P8b5uNoVfNZwnRs7cG6vuAog+TbQyrN+GeQ0FTK9O01Jt2aDg9/zbJVvO 3R+A5bc8dSd3D8kqp5FSZFR3MRjHkhxRJI9R8s+HjVJwMEBLSXbKZ24ql8zLmhDBIs /mVEQwZ/9F0cdRETaO1D+izznXpdBEDST1P8xcY0= From: "fweimer at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug stdio/15142] Missing locking in _IO_cleanup Date: Wed, 13 Mar 2024 10:43:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: stdio X-Bugzilla-Version: 2.3.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fweimer at redhat dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 2.38 X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D15142 --- Comment #9 from Florian Weimer --- (In reply to Dmitry Vyukov from comment #8) > > For streams which are blocked in writing, POSIX does not really give us= a way to make forward progress because we have to flush the unwritten data= before exiting. >=20 > Is it really the case for this program? No, this program does not have any unflushed data to be written, hence my comment about a more complex locking protocol avoiding the issue. Exit flushing is special and not specified as equivalent to fflush (NULL), = so maybe it's sufficient to put read-only streams on a separate list, and flush only writable streams on exit. But it's not clear to me if it's worth making changes here if that only fixes this LLVM test case, and the real-world iss= ues are with applications exiting with pending unwritten data. > If a write does not happen before exit (which is the case in any such > blocking), then program cannot potentially know the write has even started > before fflush/exit, so it cannot possibly expect the write side-effects to > be flushed. >=20 > What am I missing? There are cases where we must block according to POSIX. Lack of blocking is observable by another process. > > We could perhaps add another flag to fopen/fdopen that indicates that t= he stream should not participate in fflush (NULL) or exit flushing. >=20 > Should we worry about all of the existing programs that will start hangin= g? Andreas Schwab wrote this: =E2=80=9C This has been part of SUSE/openSUSE for several years, and I have not seen any complaints so far. It's more likely that you get a crash during the unlocked access to the streams. =E2=80=9D This reduced my worries considerably. --=20 You are receiving this mail because: You are on the CC list for the bug.=