Message ID | c4f64515-fec4-24dc-47a2-76b091718530@oracle.com |
---|---|
State | New |
Headers | show
Return-Path: <libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=<UNKNOWN>) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=V7tNWIaQ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NHYdC5MG0z23lT for <incoming@patchwork.ozlabs.org>; Thu, 24 Nov 2022 08:08:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 372E9384F6F0 for <incoming@patchwork.ozlabs.org>; Wed, 23 Nov 2022 21:08:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 372E9384F6F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669237708; bh=zoHR3jJsZ8KlzLSfenDdeofxmepyJJcfrZ4b1+Sc0Yg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=V7tNWIaQPZF5DgMMkP6uVetzhEmsXr5ChNsoQBsaRlonPlh+dHihfjLaiXWAq3kyL 0bCtv6D5cykTy0v/rl2vYwN03S7k3M4NUEvN1FRkRx4RvfRk7V/5bgrOjzdIho0Xo9 K+1GLd1NN11RykDZwoPCpCHY8mLTog4+eXBWQ3m0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id A9138384F6E5 for <libc-alpha@sourceware.org>; Wed, 23 Nov 2022 21:08:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A9138384F6E5 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANIO0g3016188 for <libc-alpha@sourceware.org>; Wed, 23 Nov 2022 21:08:12 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m1nd890ym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <libc-alpha@sourceware.org>; Wed, 23 Nov 2022 21:08:12 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2ANJ6RfP010699 for <libc-alpha@sourceware.org>; Wed, 23 Nov 2022 21:08:11 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kxnkdnxm5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <libc-alpha@sourceware.org>; Wed, 23 Nov 2022 21:08:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O5PnHK8ijC62aeE8rdExAMYGXUHqtkwMS/5oP3ybkL/hfLiXp4iTcwG9g+69WJlZ1d1gucUHwnYr78G5a5jYjbxbzl8gEp9MIw4TFUK0/TjJTsNsnwEIyyt0sy71yYTRP/wyXLMC8J/Wbw8i/V/sDc94duBRKT6C/IrLUN48MiDwWC1gcGlwuWFa4GBxKOIPnsX0bphnszw3q/fM/zV5pZtfAZmtH80PWB2ukE5tuTVpobbKLf4PmMfRdeKeC0Qm/xsWlTdC+tMwoiUdC5xWjSyL2NzgORDXy+QfsGKksfZpXLpbc7WfhHJjwabEPk4ZskT6HBScdTFEXmAEVNThqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E3682w3fik55iGP3olNMtcepGGEPY7mpR/aJEzPWxBg=; b=bfvgNNIwwesSG774C6gQtc1vgsdqnuqPoQd7fpkI6GMBuR4W1k6o+lV0YT08dCAAFdSEciAFQ/Ko271ljgtnThhFiHH1H1ivpPfr5d6vfNDhLnrCnUZH0VBbaVoDIRcMkRcPQ1Wt+pFjDbuIBleIPgsB3J/ILtvGj/osLqgOP9Js0YFtPx82kSmVELRVAQIBt0+l4kh7uU3Oo3xfy1Vmrph+mewXbocFTioovPboPr9I5zfxKInRECHFThqybF6eswJ/xx5Y/uqQwDqVqYgIs8nJo2dB2GF8BvzKvd0ggCai1OnJzVCL5F7ZC/l6z6cfotDvd9AOyD2fCfK7m+x2Hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BYAPR10MB3208.namprd10.prod.outlook.com (2603:10b6:a03:159::10) by MW4PR10MB5812.namprd10.prod.outlook.com (2603:10b6:303:18e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Wed, 23 Nov 2022 21:08:09 +0000 Received: from BYAPR10MB3208.namprd10.prod.outlook.com ([fe80::9aae:27cb:b098:f6f6]) by BYAPR10MB3208.namprd10.prod.outlook.com ([fe80::9aae:27cb:b098:f6f6%4]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 21:08:09 +0000 Message-ID: <c4f64515-fec4-24dc-47a2-76b091718530@oracle.com> Date: Wed, 23 Nov 2022 15:08:05 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Content-Language: en-US To: GNU C Library <libc-alpha@sourceware.org> Subject: [PATCH v2] Resolve-flockfile-funlockfile-differences X-ClientProxiedBy: SJ0PR03CA0087.namprd03.prod.outlook.com (2603:10b6:a03:331::32) To BYAPR10MB3208.namprd10.prod.outlook.com (2603:10b6:a03:159::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3208:EE_|MW4PR10MB5812:EE_ X-MS-Office365-Filtering-Correlation-Id: 6758eb7c-c7e5-4436-c081-08dacd96d2c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k4GsiPpTIEfiGt5vVw144Y0eyaXc1qspNUBxlP4OYim0j1/mcv6lwevAkggg1EBT+KmCL7Z5NO6NQDC1pC7VbBnxSmfzaRMnDhtnNbsRxigik49CA32xyCXGcFchmA3AusbSvEnAFpaaeuRhe9EosOHOiaB9UyUYSFpKaWAFV+wvZXsoKtWQqzuX5apxWl/BguJRcos0IaUwFiyB0ftU8oBEjb+Y+6Zf/iHVd+cwXNVLMTf3DfD/mqGXTP+3U9g/W8NR1dHcQxJCphLMSj4xh+/Nx7EeZu8Ue7znmA669faQu5XHpONOmen/4LDV3Q3ibhqAbBC1FeyQxKq/j3ulMI+bWAENyGO/nFSW0BRaFh9dyytT+b2+xYY3SEuKSf7W2vDarMVWz67rmWQlCUQUczhBu9/z8C9TNELmCd7/c1XU9ghl4zyYYvHHhV6ePnNagG/vwknqeqpGpXV7OW38RQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3208.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(136003)(366004)(376002)(396003)(346002)(451199015)(6916009)(2616005)(186003)(316002)(31686004)(6512007)(26005)(6506007)(33964004)(6666004)(66946007)(564344004)(8676002)(66476007)(66556008)(38100700002)(83380400001)(36756003)(86362001)(8936002)(2906002)(6486002)(478600001)(31696002)(235185007)(41300700001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?X6mggXYOIjoHdCh41ZGi8BLlg7LJ?= =?utf-8?q?kBUDL4uvTmviNkdBqPHlrpnSnuRE+0FzZDKIMAoq/A52gBZYKdsbtsEFIbxixOnOB?= =?utf-8?q?IJoMxV3V45aaQffxg9TnXQNkRfnbO+Zz3lM7Wc7D9mYBBSr4AqEssov769d1RBSHj?= =?utf-8?q?KxAPP/6Vveta0E466SL8FeoBKYs2EOPK/g8pOIaeovsuegrAhKvQlh23pqtDSb5aF?= =?utf-8?q?p3GsqU6Zx77mNjHYR1f268PWIeS/Aywmk6zTMoTz3qE0cm3RGZZ3DWSqI6+AoxO5t?= =?utf-8?q?G0EvsomKU26+9t8WWdYuhc41XjpSZX75sOkZCLj/OPlFv3aZ82to0FRKtDlSL86jO?= =?utf-8?q?KXMKiQI5CSwHkVsAGkLcWTwHJNnAzN106g9rr5YdMbT2RzacSo/Hvchlk1d8bEeOF?= =?utf-8?q?1oiIrkDLHOIq8QwQ6Fxx84Cly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+XSvlwyI0LBxOULi4PqGl/LgqECVaJHUTR/zyNk+tLLrR3S8oxdEP/dx5uhRbW/wRzg0CTubjYrJxHAEmfkQiKMGghMs0HqkrtOe367Qw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6758eb7c-c7e5-4436-c081-08dacd96d2c3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3208.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 21:08:09.2585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aHRPIicndHQmXqH6IUk8lwlKmulZ5SJnSh1hsETDBEjPvlIlxVKTfBfvdElRplDAMNJq923entWjRy1JefdIXPiMMYmU5MaGztru7/opa9M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB5812 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_11,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230156 X-Proofpoint-GUID: vOYf0ry8W6s4iiC6bPHCse0vhiGKmR_Y X-Proofpoint-ORIG-GUID: vOYf0ry8W6s4iiC6bPHCse0vhiGKmR_Y X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset=UTF-8; name="0001-Resolve-flockfile-funlockfile-differences.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-Resolve-flockfile-funlockfile-differences.patch" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <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>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Patrick McGehearty via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Patrick McGehearty <patrick.mcgehearty@oracle.com> Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org> |
Series |
[v2] Resolve-flockfile-funlockfile-differences
|
expand
|
diff --git a/stdio-common/flockfile.c b/stdio-common/flockfile.c index 49f72c6..7c82847 100644 --- a/stdio-common/flockfile.c +++ b/stdio-common/flockfile.c @@ -22,7 +22,8 @@ void __flockfile (FILE *stream) { - _IO_lock_lock (*stream->_lock); + if ((stream->_flags & _IO_USER_LOCK) == 0) + _IO_lock_lock (*stream->_lock); } weak_alias (__flockfile, flockfile); weak_alias (__flockfile, _IO_flockfile) diff --git a/stdio-common/funlockfile.c b/stdio-common/funlockfile.c index bf44c99..b77b1b2 100644 --- a/stdio-common/funlockfile.c +++ b/stdio-common/funlockfile.c @@ -23,7 +23,8 @@ void __funlockfile (FILE *stream) { - _IO_lock_unlock (*stream->_lock); + if ((stream->_flags & _IO_USER_LOCK) == 0) + _IO_lock_unlock (*stream->_lock); } weak_alias (__funlockfile, _IO_funlockfile) weak_alias (__funlockfile, funlockfile);
From a0291671db0d92a8762de3a45fd322e471a19a24 Mon Sep 17 00:00:00 2001 From: Patrick McGehearty <patrick.mcgehearty@oracle.com> Date: Wed, 23 Nov 2022 21:02:02 +0000 Subject: [PATCH v2] Resolve flockfile/funlockfile differences - - - - - - Only difference from v1 is to correct indenting/tabs for the changes to match other .c files in stdio-common. - - - - - - This patch resolves differences between flockfile/funlockfile and LOCK_STREAM/UNLOCKSTREAM to avoid failure to unlock a stream mutex in a multi-threaded application context which allows entering using LOCK_STREAM but leaving using funlockfile or vice-versa. This issue was detected during stress tests of a large proprietary application. The cause and solution was identified by Gerd Rausch. The issue occurs because _IO_funlockfile has different definitions in different contexts: Comparing the inline version in libio/libio.h # define _IO_flockfile(_fp) \ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp) And the non-inline version in stdio-common/flockfile.c __flockfile (FILE *stream) { _IO_lock_lock (*stream->_lock); } Note the lack of the _IO_USER_LOCK in the __flockfile version. This difference means it is possible to bypass the lock in some cases and not release the lock in other cases. Either way, it causes trouble. The proposed fix is to simple add the _IO_USER_LOCK guard to the non-line versions of flockfile and funlockfile. Modified files: stdio-common/flockfile.c stdio-common/funlockfile.c --- stdio-common/flockfile.c | 3 ++- stdio-common/funlockfile.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)