Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2229967/?format=api
{ "id": 2229967, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2229967/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/94933ea56cf84f067c5e7bb7a67eb39f9d9384c0.1777424201.git.ashamil435@gmail.com/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/1.1/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<94933ea56cf84f067c5e7bb7a67eb39f9d9384c0.1777424201.git.ashamil435@gmail.com>", "date": "2026-04-29T00:58:12", "name": "libio: Fix race in _IO_new_file_init_internal initialization order [BZ #33785]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "05fb4154257b09644880b76f2b7ebf7ff4a1744b", "submitter": { "id": 93241, "url": "http://patchwork.ozlabs.org/api/1.1/people/93241/?format=api", "name": "Shamil Abdulaev", "email": "ashamil435@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/94933ea56cf84f067c5e7bb7a67eb39f9d9384c0.1777424201.git.ashamil435@gmail.com/mbox/", "series": [ { "id": 501967, "url": "http://patchwork.ozlabs.org/api/1.1/series/501967/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=501967", "date": "2026-04-29T00:58:12", "name": "libio: Fix race in _IO_new_file_init_internal initialization order [BZ #33785]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501967/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2229967/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2229967/checks/", "tags": {}, "headers": { "Return-Path": "<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "libc-alpha@sourceware.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "libc-alpha@sourceware.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=pVfPvflB;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=pVfPvflB", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "sourceware.org; spf=pass smtp.mailfrom=gmail.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=2a00:1450:4864:20::22e" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4zTC1H2Pz1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 10:58:49 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 6B7114BBC0CB\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 00:58:47 +0000 (GMT)", "from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com\n [IPv6:2a00:1450:4864:20::22e])\n by sourceware.org (Postfix) with ESMTPS id 561A94BBC0C9\n for <libc-alpha@sourceware.org>; Wed, 29 Apr 2026 00:58:25 +0000 (GMT)", "by mail-lj1-x22e.google.com with SMTP id\n 38308e7fff4ca-38cc8708d76so104546741fa.3\n for <libc-alpha@sourceware.org>; Tue, 28 Apr 2026 17:58:25 -0700 (PDT)", "from oops-lab ([62.152.34.188]) by smtp.gmail.com with ESMTPSA id\n 38308e7fff4ca-3924fa7cc7bsm1043291fa.27.2026.04.28.17.58.20\n for <libc-alpha@sourceware.org>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 28 Apr 2026 17:58:20 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 6B7114BBC0CB", "OpenDKIM Filter v2.11.0 sourceware.org 561A94BBC0C9" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 561A94BBC0C9", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 561A94BBC0C9", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777424305; cv=none;\n b=ZQv1KI8yJEY2bzxOKKvKoeIIR/WsBvRyEMci84K4wqaBv75Tdb+szVDS7GZd8ZHalsBDSnNS4ohyGA6i36fQ6NTMOTL+mgJ3UHvWoc9d1NYGseC1yDzPjH+DZmXAiDSjxeBLniFafaCjRq5qCXB6E4uBqGx2y39SvRvSHH6M1p4=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777424305; c=relaxed/simple;\n bh=sW9+UiSrwkWTUV6Myb4JtpyeoV6mYlJ6rYs6zwu73wI=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=KaoqbHjjrpowBMJHKK3U7nphy+EiZSJ8DMH5Q17rme3f5XON33iiIhd+GZiah5/29Yiqse/Z0hy229sKh/8Q93MY02bMz2mXG7zv1hJeprEj9dKioTDtbW1PMhps+SZsjPTxAp3FBaJTWb5vRIF2r8vxkk55hl8yfaMOKVkUcxU=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777424302; x=1778029102; darn=sourceware.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:to\n :from:from:to:cc:subject:date:message-id:reply-to;\n bh=xo5v4BvlxUWpl4H87On6D4X3YyO2MlEG++qH4vTSZ0c=;\n b=pVfPvflBm/3z4iloZInIIJ1JI4I+4Q5l7BS+AkyhYt1LUqcJ3KYKNBUjaQpQDslEUw\n fCixb6XckflJuMV0rK/xiP74Tvs5OJnb6EUjlj62l/kVRVYg/dcBKSQzU3K9US8+mjzn\n MTFx2EysMnAp/RmFB2zSzzYO1NpniBBB5HZLFJtu7cigEYG4YFUp7+GCIG9N318Ub0kb\n yTdBMw3q7GjXBlCbBSpRkMegnsQ/Cisy+/kn7Bg3CMI8x2AOqAmNIYx4tDMyCk3AOn1J\n WUEmzvPdTqlbJ1MX6Hx9Kg9+PDG10KDMICv7nJXq2om4UnpOZlZAzg+pIRB5d13nGlRG\n QLaQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777424302; x=1778029102;\n h=content-transfer-encoding:mime-version:message-id:date:subject:to\n :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=xo5v4BvlxUWpl4H87On6D4X3YyO2MlEG++qH4vTSZ0c=;\n b=bTsfmIhfCab+xg9C1Xe6luiGKQdHjcuelBULjBXE7tvEMdmOLkAUBUfewy93UoxXgp\n pHRhCyut/00kJYPlnYelceqmaNKnPmgPKL0y07vcJfeIcAoXGAjBTwF2qRpBwMkSlpkH\n kEDOE3q7NxOJtsdxPnbagcHa0PpzApzxmEYwyBSaSrd1TVGiPo4yd8DsqxVztHvTwN2x\n 3fPHs8I+rY8Z6ciSSw3ro13iaOXZl5YNFDzAO1lTT+5Ka4Ti5YJ86hwJ8zmU8saKIv2q\n K6BpEEZmPueOtgwmkgQkb446vcQy+74EYuRyKwCzpSrVRvVGM+ScDgwWBfXrPlToRfBe\n Uj4Q==", "X-Gm-Message-State": "AOJu0Yzd0VIVNpamoTcCrM0p7DFmcOz6B6EV+j3wNwJrFp1QzzejW64S\n B9uOVG3ag1gfJ3u17CHVE2UPvqXmL67oBaufyOpspM6UKQ3RjgUxKbCgGCxh0oDy", "X-Gm-Gg": "AeBDieuQPCYCIHM98iqhgSHO6tg8ERAE+rEomKB9weGOLJWJAGsgktFbqtoMydZAYup\n /mUf64Dbm9PR0+6u3pfn5gEhsjb8OhNVDhwFN2fmDjoZQcsVe4TiGlygEaR+V6DG2GGjxwHDPAu\n T28gHNsMd+7hHgDRM5vJO2XqWvN8jqoTsEG2zsEqL00eyLlp3YOKuhMcw1cy2a7Dqr9KnALrsoE\n 0X8PbphQxKxrZLCVG7ZpthA1DSCL3TnUy/VQOvfRjnRTLEvFkYAeOQt9veC4txj1xgqzS2Rxaae\n G09jrsjL7friFWIOyOlE0/e7DM1AilQEn/eZIA7dSa/WCkuXmyqsc1SNw9uRnXpn4nfwWWSE3Pj\n M7xB5aEftmIqDMFTrHdO8t18K6PM42phuuIrHgaRN0TtUeglUbdVA3rYG8DxsUVvf73A/S8FU4j\n XpuTDDAqvJZ8WuLIHT1FrsHAwlL4lKD2JW7LxpR/eRByzu9UGVWbgMbCHswlrHPxNM0r6Hka3BV\n L9LxPVI7tk5fr3nSUL1B3dHjVes1E4tnmo=", "X-Received": "by 2002:a2e:bc82:0:b0:38e:1da0:916c with SMTP id\n 38308e7fff4ca-39240ce806bmr20223041fa.13.1777424302088;\n Tue, 28 Apr 2026 17:58:22 -0700 (PDT)", "From": "Shamil Abdulaev <ashamil435@gmail.com>", "To": "libc-alpha@sourceware.org", "Subject": "[PATCH] libio: Fix race in _IO_new_file_init_internal initialization\n order [BZ #33785]", "Date": "Wed, 29 Apr 2026 03:58:12 +0300", "Message-ID": "\n <94933ea56cf84f067c5e7bb7a67eb39f9d9384c0.1777424201.git.ashamil435@gmail.com>", "X-Mailer": "git-send-email 2.54.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libc-alpha@sourceware.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Libc-alpha mailing list <libc-alpha.sourceware.org>", "List-Unsubscribe": "<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>", "List-Archive": "<https://sourceware.org/pipermail/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-request@sourceware.org?subject=help>", "List-Subscribe": "<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>", "Errors-To": "libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org" }, "content": "_IO_new_file_init_internal linked the new stream into _IO_list_all\nbefore setting fp->_fileno to -1. A concurrent thread that walks\n_IO_list_all (for example via fflush (NULL)) could observe the stream\nwith an uninitialized _fileno before initialization completed.\n\nSet _fileno = -1 before _IO_link_in so the stream is fully\ninitialized when it becomes visible in the global list.\n\nThis is the residual concurrency defect noted at the end of commit\nb657f72fa3 (\"libio: Fix deadlock between freopen, fflush (NULL) and\nfclose (bug 24963)\").\n\nAdd libio/tst-file-init-race exercising concurrent fopen/fclose and\nfflush (NULL) to detect regressions.\n\nSigned-off-by: Shamil Abdulaev <ashamil435@gmail.com>\n---\n libio/Makefile | 3 ++\n libio/fileops.c | 2 +-\n libio/tst-file-init-race.c | 66 ++++++++++++++++++++++++++++++++++++++\n 3 files changed, 70 insertions(+), 1 deletion(-)\n create mode 100644 libio/tst-file-init-race.c", "diff": "diff --git a/libio/Makefile b/libio/Makefile\nindex 93656466df..7e448295e3 100644\n--- a/libio/Makefile\n+++ b/libio/Makefile\n@@ -107,6 +107,7 @@ tests = \\\n tst-fgetc-after-eof \\\n tst-fgetwc \\\n tst-fgetws \\\n+ tst-file-init-race \\\n tst-fopenloc2 \\\n tst-fputws \\\n tst-freopen \\\n@@ -160,6 +161,8 @@ tests-static += \\\n \n $(objpfx)tst-popen-fork: $(shared-thread-library)\n \n+$(objpfx)tst-file-init-race: $(shared-thread-library)\n+\n tests-internal = tst-vtables tst-vtables-interposed\n \n ifeq (yes,$(build-shared))\ndiff --git a/libio/fileops.c b/libio/fileops.c\nindex 8067c0a9cf..9348d7c3a1 100644\n--- a/libio/fileops.c\n+++ b/libio/fileops.c\n@@ -111,8 +111,8 @@ _IO_new_file_init_internal (struct _IO_FILE_plus *fp)\n fp->file._offset = _IO_pos_BAD;\n fp->file._flags |= CLOSED_FILEBUF_FLAGS;\n \n- _IO_link_in (fp);\n fp->file._fileno = -1;\n+ _IO_link_in (fp);\n }\n \n /* External version of _IO_new_file_init_internal which switches off\ndiff --git a/libio/tst-file-init-race.c b/libio/tst-file-init-race.c\nnew file mode 100644\nindex 0000000000..f47691de94\n--- /dev/null\n+++ b/libio/tst-file-init-race.c\n@@ -0,0 +1,66 @@\n+/* Test for race during FILE initialization in _IO_new_file_init_internal.\n+ Copyright (C) 2026 Free Software Foundation, Inc.\n+ This file is part of the GNU C Library.\n+\n+ The GNU C Library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ The GNU C Library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with the GNU C Library; if not, see\n+ <https://www.gnu.org/licenses/>. */\n+\n+#include <stdio.h>\n+#include <stdatomic.h>\n+#include <pthread.h>\n+#include <time.h>\n+\n+#include <support/xthread.h>\n+\n+static atomic_bool stop = ATOMIC_VAR_INIT (0);\n+\n+static void *\n+opener_thread (__attribute__ ((unused)) void *arg)\n+{\n+ while (!atomic_load_explicit (&stop, memory_order_acquire))\n+ {\n+ FILE *fp = fopen (\"/dev/null\", \"r\");\n+ if (fp != NULL)\n+ fclose (fp);\n+ }\n+ return NULL;\n+}\n+\n+static void *\n+flusher_thread (__attribute__ ((unused)) void *arg)\n+{\n+ while (!atomic_load_explicit (&stop, memory_order_acquire))\n+ fflush (NULL);\n+ return NULL;\n+}\n+\n+static int\n+do_test (void)\n+{\n+ pthread_t t1 = xpthread_create (NULL, opener_thread, NULL);\n+ pthread_t t2 = xpthread_create (NULL, flusher_thread, NULL);\n+\n+ struct timespec ts = { .tv_sec = 3, .tv_nsec = 0 };\n+ nanosleep (&ts, NULL);\n+\n+ atomic_store_explicit (&stop, 1, memory_order_release);\n+\n+ xpthread_join (t1);\n+ xpthread_join (t2);\n+\n+ return 0;\n+}\n+\n+#define TIMEOUT 30\n+#include <support/test-driver.c>\n", "prefixes": [] }