From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2123.outbound.protection.outlook.com [40.107.102.123]) by sourceware.org (Postfix) with ESMTPS id B44A0385DC39 for ; Mon, 3 May 2021 16:56:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B44A0385DC39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cornell.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kbrown@cornell.edu ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hExLirrKKyljNH4eN7q9zja3QUNLjaK8xlicKAMzc5wkYzRgtb3L4WJgHHhLzgPEOrJaoRSG2UzpPlz3ZPFVTwcLtEq2jjfDXaprbLUcDonjedyMNC/ieDUrEp02xbxagQhRw3OzRqrNwALQFZLJn2/tigTyag7tatASyLj7ZoKdV5kVXfbe5RxFdDG7j2FPmVRj248ZVO70GqhqKc3G8JKkuz3OmjjyF15IJ/lOJpUEM+ooOd0JQHFtnL3MEiS/a5TXAjUEcDvlDo0NSAB2anUHnKBxEWCcy+w0U6kMrwe8voL3bm71n7ABw1LUYRsYuK+8GtSlwHbyqh9N5M8Zdw== 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-SenderADCheck; bh=ppXNlgJXQOOHSOsputt5DvrYU6B1ebwG8HCLwfHN9qo=; b=f9IN6Po/g+2FbltxanwLaHZU5Jpe1spwg59P/cZ29fAG73tcZ+FhLbOnuJEe5edc02A2EvYI3fnhnRfZAQlevtVdVDmnKTn+Q96FnByOKgoMfvLI9JahiUW1bti77UdPFj0UhQImMegTy1ZH8n2dfLQ1fSOuqkN506juDNrejPQyqtK13yPCIgf7PHPt76YxtLppFn4RMfyjFo1pTR/w5/o6thqkSkbBll/6gheFnXRW4NcAgzESm+Xk5SphdcWrQkzeoX/LITI7cmzdWpOgDx7kyDCIgFj5L4bnsqUlCbuQ6Fpxa6j8atGi3YQCPCs5qEsr+e7ofDnKVYOL4UtphA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ppXNlgJXQOOHSOsputt5DvrYU6B1ebwG8HCLwfHN9qo=; b=UQWz1mA07uQzCJIWcqCBkU1NDUwklQbus9Z7GqlCCcrjZoG0JFRIPw9cWsNh11fZBMra0dTqhzJsCevcPt2hpTLf7GDsaFuLlVPjaSp2hNFkZz6GrwCbYbqbZSzVxRTb6VQLIIKEcMRo91YQRnwHNX5xpzS/rPBO7gljb0MvSNA= Authentication-Results: cygwin.com; dkim=none (message not signed) header.d=none;cygwin.com; dmarc=none action=none header.from=cornell.edu; Received: from BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) by BN6PR04MB0244.namprd04.prod.outlook.com (2603:10b6:404:1d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Mon, 3 May 2021 16:56:03 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::59f8:fcc4:f07e:9a89]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::59f8:fcc4:f07e:9a89%4]) with mapi id 15.20.4065.039; Mon, 3 May 2021 16:56:03 +0000 Subject: Re: The unreliability of AF_UNIX datagram sockets To: cygwin-developers@cygwin.com References: <58da34ac-f2b6-d8b2-e872-834cfcb1ab51@cornell.edu> <6cac30e5-56fc-5bf1-b85b-fe6b91bc5e97@cornell.edu> <16e1d55e-15ea-6c0e-04e4-aa6cb2c0c1bd@cornell.edu> From: Ken Brown Message-ID: <5564e10e-9099-fc5a-3a8d-c2ffb8ca4cff@cornell.edu> Date: Mon, 3 May 2021 12:56:02 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [24.194.34.31] X-ClientProxiedBy: BLAPR03CA0148.namprd03.prod.outlook.com (2603:10b6:208:32e::33) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.0.18] (24.194.34.31) by BLAPR03CA0148.namprd03.prod.outlook.com (2603:10b6:208:32e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Mon, 3 May 2021 16:56:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: feeba228-88c3-45e1-5ef1-08d90e545625 X-MS-TrafficTypeDiagnostic: BN6PR04MB0244: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NZGUx35Tg96JCOR5ClxocrAqp7j1wlXTZvsF8imWB3jApEF0e7eBip01sLY9jLvCKKINIhJoQt1QKm+yvJP7UYPQjxEgkt3g+BynzrTqfS3nKv9MBzzJ4yqST7q2lUko4pEDC/RDSFL2Q9RNvoLWMqZNWLXCbNGxIhebutt/ZiusvuqF5v0bKwQdGUYLwZwlsGvD0ndqiUX23A8RtsNHzkzp3s9er2SGsBP0PoZyxSoms+DSCD7XPP7I7Mh5a7/iQxInD8MHiHh2ft+QuhjRWbusF4tFZLhtHKnAwVjq50kstIkDTNyI6NM3lo63cxutYiXUorITskuY7ePePJ6ziz2Azw+1zCy/ozY6YbmFwOsMAG16CXkP9V79yXahd8s0i/KIwCL6Oo19j7wypRhq/NmodSFTmDqxlCFS6iWhTyczjXwBpGqxwimjxfGHvO+yPK62Aa3J0u5q8A9ua0mIXezbg9cwCH16q13Vm+TsGsfbN2YRft5eu87UTy1etsR5WueF4vYgCqskO12850w/IrI17Fo2uqueXylMmcoaZrOl7TgPpv1ydJf2YIpbNMLEGBWsqRiOuKkbSD5xmI3WSe8pXLmTS/WZOTXWgAyMCiO84dezXt4/dCy2LNWoVnZHHXRAiyMwFyHEZezVD4ZRADJ8bS/mEu0GxaIPZHxX4XuQjP54Ot7AGR7TjS7w9DeOBE7w/ZXpOHEN9oBibggUfw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(39860400002)(136003)(396003)(31696002)(86362001)(8676002)(31686004)(38100700002)(2616005)(38350700002)(75432002)(956004)(6486002)(36756003)(186003)(316002)(53546011)(478600001)(2906002)(786003)(66476007)(66556008)(52116002)(16526019)(66946007)(5660300002)(8936002)(6916009)(83380400001)(16576012)(26005)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?EoaTqcC3ziuPXEf0V6NX0b0DJo7G0AryKgfYHhQHoHXlxbE5lVm5Xm2C?= =?Windows-1252?Q?MUFIhx8u/R5eLuK13fPc9uIws6z7LRvWONCJ5pYVAlKOaWvtkzUATHvM?= =?Windows-1252?Q?uoYx1FI/YTDYHdOjxXCbDnCjSntA/S7utxqTHQUABy8LhsVLcnT4EJPN?= =?Windows-1252?Q?NBkULdEjyJusBu44gV8K2VWnwyXTX2RwTWUEXlCYR+LztQXXju2nyvmy?= =?Windows-1252?Q?o0TiUsLbF7eC6Cx+7iCjdowA1P9LdSwljMRiZWjzBPFm4a6QWKicYWjK?= =?Windows-1252?Q?Rywfui2ilt15hjeOJSRQ9VbGUmz0RyJHtRYFDafMS3P8oZWyUfRiY5i6?= =?Windows-1252?Q?syfXg5ujlOhjUfguKws7ZXTEy5MkjWoYlBcPxoIv75o8pRzMc7UZ+A3r?= =?Windows-1252?Q?eVyJ8w61brguAYj6DYjZx1s4Dsgwsaz0R7y3nAoTFb1sWPzBFye8Q7X/?= =?Windows-1252?Q?uVEM59y8iYtY6u9FX6YTmYPI+E7qa1KYao7qXlIV66vC3PlPGyhjrkrn?= =?Windows-1252?Q?f3feMO64YVEu5XwOitxKNR3mE8os6gwekodabeFs4kN9Z2fk+NINcf+y?= =?Windows-1252?Q?UiAWqgC+FeZVVZ+Rh5gzxM0/LXeC6HvXySKh8gVkqhhuF5ZYvEM6He5F?= =?Windows-1252?Q?CLvou2M5Oj3rQqaOhBvTfAwlBMeis1A8zguikBkiRXUmt0vanrDJC9Rt?= =?Windows-1252?Q?xjos6hktmZJqX93XgFiWB70O9ytLCk7jKAMpZskYJF/92g35JzBVIbwn?= =?Windows-1252?Q?DyTz1b8zHEjyc8AVshciO25Qc2PQxv/JzSBLgj9VPmnyoFqmSwmIOXK/?= =?Windows-1252?Q?lmLNsjccrEI8YgBdDf0yeC2F8Tnxq2xRL0cOgtZEpm8I5O1JYCyvIfrp?= =?Windows-1252?Q?LFIOuvSqB1PRDxwC0vwHIde3ezjBKo9WkS0tGAItp8kj5yJG09dj7K+Q?= =?Windows-1252?Q?UDQp8W5qQJ8ild+n1QfNFGdpt5bRaSLAS/Nzjpq0mh2MUTmdNcpMojaE?= =?Windows-1252?Q?0QLA+6PiBjRcoIf7ZBPCbsLSdFR055rOIZYHcIvaHBSBoqsLq72i9Cp/?= =?Windows-1252?Q?oceRrVM+nSvow3eUfGmb5/jAcw2GSExeUHqQDJp4s8ET7JPEi74X0vNs?= =?Windows-1252?Q?RyPwJd3c8e4vtYo32KPi8sPdPHxinSbm4KvDEBqBTAcbS42HHBYsin9l?= =?Windows-1252?Q?VsbYN2pfihp0sVm+AhKeIkRNr6BVII6oK8kXdaB2MaH4eS33zI1sMG3s?= =?Windows-1252?Q?y5FCd6KPd6OC6mNElIb2YifKK+iLr1+KLUhuMiijNg5Weg9rLW1adEvy?= =?Windows-1252?Q?IgugxDVHN0qMAZgeKPBsh3hvGaBGvfl2/yfESJLlpb0MqGIc41jFT4+g?= =?Windows-1252?Q?d8lImI3dCM1KVuvfCO9sptfGeEJ2QJZkhgwrWPch0ziqO011KMZjAgBZ?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: feeba228-88c3-45e1-5ef1-08d90e545625 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2021 16:56:03.6466 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1ilcMWVvcNz1qamnKd/jgqdxQT+bVXcYJO0/FAmWxi+kbABIIx1JnKw6nqkDJzrE9HFh1zCMx6llBFl0G7qBJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0244 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 May 2021 16:56:08 -0000 On 5/3/2021 11:45 AM, Corinna Vinschen wrote: > On May 3 12:30, Corinna Vinschen wrote: >> 1. As you noticed, the socket descriptors are inherited by exec'ed >> children, but the mqueue isn't. So we need at least some kind of >> fixup_after_exec for mqueues used as part of AF_UNIX sockets. >> >> 2. While none of the mqueue structures are propagated to child >> processes, the handles to the synchronization objects accidentally >> are. >> >> 3. Note 1 and 2 can only be implemented, if we introduce a new >> superstructure keeping track of all mdq_t/mq_info structure >> pointers in an application. Oh well. Bummer, I was SOO happy >> that the posix_ipc stuff didn't need it yet... >> >> 4. As stated in the code comment leading the mqueue implementation, >> I used Stevens code as the basis. What I didn't realize so far is >> that Stevens simplified the implementation in some ways. The code >> works for real POSIX mqueues, but needs some more fixing before it >> can be used for AF_UNIX at all. >> >> 5. I hacked a bit on an mq-only mmap call, which is supposed to allow >> creating/opening of named shared memeory areas, but that's a tricky >> extension to the mmap scenario. I have a gut feeling that it's >> better to avoid using mmap at all and use Windows section mapping >> directly in mq_open/mq_close, especially if we have to implement >> fixup_after_exec semantics anyway. >> >> 6. Ultimately, AF_UNIX sockets should not run file-backed at all, >> anyway. Given that sockets can't be bound multiple times, there's >> no persistency requirement for the mqueue. > > Got it: > > 7. The idea of _mq_recv partial reads is entirely broken. Given that > the information in the queue consists of header info plus payload, > the entire block has to be read, and then a new block with fixed > header and shortened payload has to be rewritten with bumped priority. > This in turn can only be performed by the AF_UNIX code, unless we > expect knowledge of the AF_UNIX packet layout in the mqueue code. The partial read is actually OK as is, since it's comparable to what happens on a partial read from a pipe. I already have AF_UNIX code (on the topic/af_unix branch) that deals with that. A boolean variable _unread keeps track of whether there's unread data from a previous partial read. If so, the next read just reads data without expecting a header. Ken