From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2133.outbound.protection.outlook.com [40.107.102.133]) by sourceware.org (Postfix) with ESMTPS id 0CAFF388A02F for ; Sat, 17 Apr 2021 16:05:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0CAFF388A02F 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=kDpj63O0sznZ/e9pOaw/N1WxA4bJljIh6DqgVSL41Ez0H0VKUnLuNTc5NhRyuVqZBFQ3BxdcB1yKnyIfNJpp7+YAZtUbdNCIO7vXIkpQwEQmcGYMxU4/y1pJy9U2cD3suShhfBEhz/uUMqi+Muzo245yZqAGCVDx7qJmMbz7Y5ZzQdsmPSbVvCKOqwglXrNOFSWiv6KAUqMbPE1Bu0gNSowjiUo3tqnEzdpZvxNSPRhLgYFsvnc6ocmACjjuz/GYYLnmsVkLKe1inqyQQuMdjHVA9Pz+40nrrcNBX8TsbDh703pbWtdlLAJ0M9SfiLbmzSGqGcoOylCbC/8+xYtY/g== 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=rqGJQzglSc6ZK8Gk2YnpVuiJm8dg7qHRhHpcjdD0bV4=; b=dATzsyLiSZG0G/g9qjUXCiW181BUwJWrcbW1YvcWgsedx4+9ngovRhfJjp//rTdbZApYn641/3+JkXOMV/xaNHEqUulJvs2DIHQ3vXUfhNJaS4feszYOGpmLEmyR3+L7Ern1OYxD9or9WyUs9QRXXXmTJRKMKRpBoUeM9xDbD7phrdki0PxFhdX5w7O2/KsSsc2jfEcX3rtkpufsiAgdj2fgA5eqIV8uoXk8rqw4p8UQU1UgrL/U90GpjzOx2K0rGij4qKoa/uL88/uo+aHlbSYrZ7TH1eHc+a8pyG6Zfq8VlOahpKqY2fhU8TaRVZzxNsiVfjPS56YJqWGY783HLA== 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=rqGJQzglSc6ZK8Gk2YnpVuiJm8dg7qHRhHpcjdD0bV4=; b=QsxwBN0OBpKxiMQy/IqEZM1Oi13mxVOGw2HTv1h+fp2NUi7RRAdtPM+qJkyRcRq3KCOtCXNtV9TJe+bps3p9h1PBLsx9ti4MdAmvcnASNVndE3o9HnTMd6LFBwn3KCyL0TtS+zihGm9zhfoXek4Js0AOeiVKF6FdOwZY7hjnD5k= 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 BN7PR04MB3842.namprd04.prod.outlook.com (2603:10b6:406:ce::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.21; Sat, 17 Apr 2021 16:05:09 +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.4042.021; Sat, 17 Apr 2021 16:05:08 +0000 Subject: Re: Problems with the (new) implementation of AF_UNIX datagram sockets To: cygwin-developers@cygwin.com References: <1cfa2d74-eaa4-e3be-9fa5-519952026aef@cornell.edu> <9db1d7ab-fe47-6f8c-db65-c9fe5e18952b@maxrnd.com> <8cec7dd0-5a0a-1e38-66d0-3c92854d1a69@maxrnd.com> From: Ken Brown Message-ID: <27dadaaf-68d5-a529-2c87-9a08ef1f86df@cornell.edu> Date: Sat, 17 Apr 2021 12:05:06 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 In-Reply-To: <8cec7dd0-5a0a-1e38-66d0-3c92854d1a69@maxrnd.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [98.159.211.121] X-ClientProxiedBy: BL1PR13CA0162.namprd13.prod.outlook.com (2603:10b6:208:2bd::17) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.155.93.87] (98.159.211.121) by BL1PR13CA0162.namprd13.prod.outlook.com (2603:10b6:208:2bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.7 via Frontend Transport; Sat, 17 Apr 2021 16:05:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c34f4d3e-ab91-4bae-7b6a-08d901ba9260 X-MS-TrafficTypeDiagnostic: BN7PR04MB3842: 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: 0xRlXOx+ohw85oCAeWVltj+28AoMkEJuSpCTUJCJIdoCKhe9bV2JITIMVFmPjQFlDVf3JVSersmfJkaXVXJqPMkN/QwQmOepFLfzu9//acKHJ3l0yVz8O+Eh2S93vZb0gaqHkI8mxJxL1LS/0VjfId/IMQSrqkzpS7VEcM8Za9D+D/70xp+DiUV5OBcEbiG92z8RFvXWaK9DqWV3W065hhj2sDxFi43SlgPUZgtEM3VB7kGSoSR2yKHW/KDMne8KKQA61nI9whdhcHGgy0kO2WdhuOL9gT9L6vA6eBtu+65vge7ycaIugzYu0lPjmBfLhCMYozbAFrgfnthmazPpvVzSlu3wKbPvZdLZbEDobKnzdgWjj5g7H2KyTKjiB3FKExZLEKazHrq6qILJFAFYMashtw7Lw7FGZiYWfyi2UA+3AIQ4NZArYLV67p1wrYW0ft8a24xNvjGCpRaJI6307bgH/pd8NF3IDn9iOquzvqXdgLDvo4MJgdLrJSbj91+QfbaHGlGzTJKQU5s0CpVKtlmuTvCJqn1o0Nd/vLVDjsOliv9M7c7KI5mMfKdzwAXxlEFI9RLrtW5BjXZIj0CT/wh3D7U94PZTyhzouO7lo5jSYVamyKOm8HD46obMsllvMEBzMy/XClY/4RTj2dYUemol2OSDn63Hlxy7fRdow7Yq3i8rQQgPyvDdGAu4vZ0st1TPLKbqq9h4Zo8f/m5XVm5fNCPBdfQ1Qt4W5qNeBH1Neo7IduUjsHTG4PQ6k+8mYL7A85775n4tcXjsGmiFZduYvlM4cTCJIdxjkyBaje0= 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)(136003)(39860400002)(346002)(396003)(366004)(8936002)(6486002)(26005)(52116002)(2616005)(6916009)(956004)(8676002)(16526019)(186003)(5660300002)(966005)(786003)(53546011)(36756003)(31686004)(83380400001)(75432002)(86362001)(478600001)(16576012)(66946007)(316002)(31696002)(66476007)(38350700002)(66556008)(38100700002)(2906002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?c+VvY+Vo5SfOZ5aywTZCCNqZD8lWoYF5Uh+CRQue6t/P0AWx1vBBozEq?= =?Windows-1252?Q?q/Le2FRbQ1nx5yrfv7Ymr6UOL5kXq8ypzMjbb/ruV6BAxffDV+mcayMv?= =?Windows-1252?Q?g27B2BAT15ev0+juhLxP60KmXJy7tnrza0Mf3ki0nAnhZiiA19fXa1hj?= =?Windows-1252?Q?BYpfuRbU8PuPYHN9YtdDwNlvpmT5HOIv3LG+JiaHcpXPPgOvuKfGkqXu?= =?Windows-1252?Q?SU0SPxsP+JJ7m6RiOav4o2tkVCyrl7YuKQNBKm+gAfcLkjaM7MkZRafj?= =?Windows-1252?Q?CBkzNfMJ0TfvJ8uKCEVdlNslBmaTRqyToRQz/rf0GxTLUTZIpSvlnqwV?= =?Windows-1252?Q?Meztn7HajTwYZ/rqXAy4+k2uPYNu83QZlYRqGz6vhgVVmFE1d9fRgYFi?= =?Windows-1252?Q?JebLeB+Zj0+c+xVBggEHW1AYQ0uH/yXum/aUBXN7ODRNHItkoyknzniS?= =?Windows-1252?Q?kzbxC2ytPpiS3brl5fhp/pnn/t/zxDx1oEU5t/QjW3A3iZO6N1WorhMs?= =?Windows-1252?Q?v+kQekbx0JILLNC0NEgHPZDoxEPNjDiEpfWvfX+aKyzI0nPxJ/W6E1UB?= =?Windows-1252?Q?mB932fQ2OKFQK6YfE0p5aMWXzeer9ltIkE9BGOEkwo4DO5hJjaHSomtG?= =?Windows-1252?Q?Ib7ddE/g8zP+O0W0iAxnUWncMbHqREU1Q8lesb3omqeE6m5P/Kaeus/r?= =?Windows-1252?Q?s7kuPWSP5W/9IRRHTJY01Y83Q4M3fsaHzi5qw3hQk88LPYFjDtQxslus?= =?Windows-1252?Q?b2G2SUxy/nZ0anL4LkgyRDS/NjBGeDmQvbCxSbROQ53b6ITvtgeDSI+Y?= =?Windows-1252?Q?OyUFkAodjh55cOEkURG9b+PsekDoaCVK5buucS+g1Jb12SfQVXHwC4oU?= =?Windows-1252?Q?RV2M6d/ukJqa3OGx5nLgT6Qh2zeTxrxWxZMbnDrw16tgC9WQA3Cgssp9?= =?Windows-1252?Q?6uO0Nf2TywIjDhCErNceg/AjKFdkuftbiz8Tt/BccCYA6YHAgPiLempi?= =?Windows-1252?Q?e+48ncfFVsBBEmNMPTXMtguBnsG99HDXrns41E02VOAVp9wd6brbRRW5?= =?Windows-1252?Q?mE0CIO/D9AAF/aA9Mi5U8K04W9kr40glg08QermiXlz8bToquNU9W9XK?= =?Windows-1252?Q?4IxjOpiotF5VKnLUkNsbQk5UpFm07gtmWOBpSm2PcBWO0jBvW7NWoSgi?= =?Windows-1252?Q?k3+lQXwSXx0VeHxcRvXAEiiK9YW2299uQD6C6Im3KMbdHPGJqFvFf7D8?= =?Windows-1252?Q?C4uTwzJLFj2MPyJHQyr40iqXH6bXwLSpVFAigQob21IBdS3U0QGM14FJ?= =?Windows-1252?Q?+cgbHf+meByplsBEbBfX2qLUz2qlaO05slefts5hqDGVE5JUvgGPVDcc?= =?Windows-1252?Q?kzkyqCuZ2uEwQWfm7h3uY3hi28D814Ct2EuSNwwjlYAVz8Yml3uJL8Sq?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: c34f4d3e-ab91-4bae-7b6a-08d901ba9260 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2021 16:05:08.3425 (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: CZD7u2MnL+0UT+XL4QU7aYrEixLEi1tpLqFOMP98cKkiCcGjbRzVCnJUz6lZ+B1gTCi36KqOYakBkL68S6sP3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR04MB3842 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: Sat, 17 Apr 2021 16:05:21 -0000 On 4/16/2021 10:54 PM, Mark Geisert wrote: > Corinna Vinschen wrote: >> On Apr 15 16:50, Mark Geisert wrote: >>> Ken Brown wrote: >>>> On 4/15/2021 9:58 AM, Corinna Vinschen wrote: >>>>> On Apr 15 09:16, Ken Brown wrote: >>>>>> On 4/15/2021 7:49 AM, Corinna Vinschen wrote: >>>>>> [...] >>>>>>> Another idea might be to implement send/recv on a DGRAM socket a bit >>>>>>> like accept.  Rather than creating a single_instance socket, we create a >>>>>>> max_instance socket as for STREAM socket listeners.  The server side >>>>>>> accepts the connection at recv and immediately opens another pipe >>>>>>> instance, so we always have at least one dangling instance for the next >>>>>>> peer. >>>>>> >>>>>> I thought about that, but you would still have the problem (as in 1 above) >>>>>> that the pipe instance isn't available until recv is called. >>>>> >>>>> There always is at least one instance.  Do you mean, two clients are >>>>> trying to send while the server is idly playing with his toes? >>>> >>>> Yes.  That was essentially the situation in the test case attached to >>>> >>>>     https://cygwin.com/pipermail/cygwin/2021-April/248210.html >>>> >>>> It was actually one client sending many messages while the server was >>>> playing with his toes, but the effect was the same. >>> >>> Sending datagrams between processes on the same system could be thought of >>> as similar to sending/receiving messages on a POSIX message queue.  Though >>> the mq_* man pages make it seem like mqs are intended for within-process >>> messaging.  But if a datagram receiver created a message queue that datagram >>> senders could open, couldn't that provide buffering and allow multiple >>> clients?  Kindly ignore if insane. >> >> Interesting idea, actually.  Message queues already implement a lot of >> what a unix socket needs in terms of sending/receiving data.  The pipe >> would only be needed for credential and descriptor passing, ultimately :) > > One might be able to deal with credentials/descriptor passing within the message > queue by using message priority to distinguish the "message" types. > mq_receive() always gives you the oldest, highest priority, message available in > the queue. > > I'll have to look over the usual DGRAM references again, but OTTOMH if > credentials are just euids and egids maybe they could be handled as permissions > on the file backing the message queue.  If the filename (in a particular name > space we set up) is just the port number one could treat ENOENT as meaning > nobody listening on that port, while EPERM could result from credentials not > matching the file's permissions.  Makes some sense but I'm unsure if it covers > all needs. A couple of comments: First, I don't think we want to limit this to DGRAM sockets. The code in fhandler_socket_unix.cc already packages I/O into packets (see af_unix_pkt_hdr_t), for both the STREAM and DGRAM cases. We could just treat each packet as a message. In the STREAM case we would have to deal with the case of a partial read, but I think I see how to do that. Second, I don't think we need to invent a new way of handling credentials. We already have send_sock_info and recv_peer_info. The only question is whether we use a pipe or a message queue. Corinna, what was your reason for saying we need the pipe for that. Are there security issues with using a message queue? Ken