From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2016.outbound.protection.outlook.com [40.92.20.16]) by sourceware.org (Postfix) with ESMTPS id E72BA3857017 for ; Wed, 25 Aug 2021 15:58:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E72BA3857017 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIWk1OLlzjS7AyOSN9Xia4gbnHkX2oCxUrxnvT2Ka2PnLUqi2WWeiPsi9wUUfhIpg6WqusgDy/EFNcj69NNoOgaI5F40m5UZQFUwLjJE+j75R+6v3RFRyV24oD56xThoHNi4qPk8/Bw3fWXDFjTo8wHon8ZqjEMYOmc5zwyarpIOnA2Uldc/jB4ldEgLs8bX9nrT2L7EFdVefbhIivzcieHX1gQoCPYaDs9m7PbGDhWkU/PbAIZQrlEIYiTcovzukXDvSP9OmARk3LD9G9rxIeDCq+8nNVYdkr/NiHjboEF8n+2LlOK7A38YRXr6aVK+ItO9slbIdj9OiaUN52ssDQ== 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=qvwRMdwHqTCamqi0EGkkX2F74xbpFAvVP0TjXMJsgI8=; b=NboJmn2LXRJZWix+44gphQ2W80B0O34jisVEJVXCDFuMe4ZvA9GjMWNjWF3H9uvittwo7C16EbjJb73GgWf1yerkaH0NvKZ9vxs7HQz7QGEIZ/vQSMEBl1TdcCJMvHoYXi2Nor++5dG/Ii3Qu1houGEtGHbdvf6fZ7hbVU1c0raRKIBFDKUFXD+1cyI1WPc7efNr7UZuzYmF4ocTK4Gu1STE9KCpKEOPSHGpwSTz7iynhTSLbkyWA7BcZx5N5kY3sBVq3u2QGJrQbThi73ht2ek6ujwqEuMT6oOB8jn4ssYWBYXIKa0FORlkZyuGoR3ULbVrBkHLE5phhmB9fSbw5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MWHPR1401MB1951.namprd14.prod.outlook.com (2603:10b6:301:51::14) by MWHPR14MB1839.namprd14.prod.outlook.com (2603:10b6:300:137::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17; Wed, 25 Aug 2021 15:58:05 +0000 Received: from MWHPR1401MB1951.namprd14.prod.outlook.com ([fe80::adc0:8922:4de7:e7b7]) by MWHPR1401MB1951.namprd14.prod.outlook.com ([fe80::adc0:8922:4de7:e7b7%9]) with mapi id 15.20.4436.025; Wed, 25 Aug 2021 15:58:05 +0000 From: Jay K To: "libffi-discuss@sourceware.org" , Andrew Haley Subject: Re: is fork() supported? Thread-Topic: is fork() supported? Thread-Index: AQHXiWtrnWK1bzfmykWVm1UIt/hNSatkkfAAgAAC1IeAHoCBgIAAApNngAAFzACAACjogIAAC9S2gADBg4CAAGyJtg== Date: Wed, 25 Aug 2021 15:58:05 +0000 Message-ID: References: <09e0d2b62f62482b2fa1c29120a43078@mail.kylheku.com> <4da1a4e5-fbac-5d5f-b5ee-abe0b252ed80@redhat.com> In-Reply-To: <4da1a4e5-fbac-5d5f-b5ee-abe0b252ed80@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-tmn: [CaqbEEcs6LQVgGXvdJS6IQ9SJFWPaOdRQOx5D0UXbv9B8BIVyMx+sFw10RKoLAY3] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b2590a7f-8243-48bf-09b1-08d967e12073 x-ms-traffictypediagnostic: MWHPR14MB1839: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: X/nW9htYTGZ5mFG0SRBQ5f32icpfph3q/yhNI7E3Pr36VINx8HDSRsM2FLZnZkSbokW57h8+KUTJwz21PpqcdOPELwPFpwFQaAC5C1Ke0ow4te+62yW0OpnbUNMDFmzJIivrE3Dhxhh3f06RQa/N2KHwMnfhw9xsIiS9olzgwqhQiQs/tA0tZllhEdkTuxkuytqe31LEXGHPC4V+LdXWYrHpRSspXtaLSJkVI60MtYlHZgKt0xJq8r5h5cx8TiG/HmjBmh423qPWcTmPFscUzV/a/0UzdHBNozqYWyCoq6wrE8hKrLdju/1ikgY8+RZO2fmfuXExC6bOAPPVvmZdI0QbgpksLv7z7RqtqBCShM0S+kV7hVBG5ZJPlxfho2v3JktPqUdsdR5WzLSmemPDh+Vvn5nHlRKA3WS3I+DQZ0a7NFseetsF1S6jhe6u64RMyg4anM5Ra/JC+BXqLIftZ3azKEkukR9f36Egb3ONix8= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: tSzYGRcYQgRNBkQh1OR5GzMFVjLlvFXMa+1DgeSWZjDOZyrfVS3FoYiQNllt/SoLHMwZZ2TpFcgmFXXnl1MoOJPkxkMQIM5Bf6HaYH7f2aQvVuolyblGC8RUSSP+VgKdT/vmHRUqYyoqJl+zuPMMgylgedi8bku7glxTNy/3UCYXe96g2cZmocUlL5SSe7UXzffPJLH5SgP5uGquByo2mw== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-32894.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR1401MB1951.namprd14.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: b2590a7f-8243-48bf-09b1-08d967e12073 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2021 15:58:05.8708 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR14MB1839 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 15:58:17 -0000 > pthread_jit_write_protect_np It is all tradeoffs I think. Attacker can still try to write to the pages while they are writable, in any of the approaches (Apple, two mappings, two processes, etc.) But yes that does of course help. But I again I think all those methods, including the Apple one, are needed only for "arbitrary" code gen, not codegen that can be made data driven (n thunks, array of n to drive them), and the code is therefore constant, and there "just" needs to be a way to make multiple copies/mappings of it (to expand the pool of n by another n). vm_remap is the Apple function I was thinking of. - Jay ________________________________ From: Libffi-discuss on behalf of Andrew Haley via Libffi-discuss Sent: Wednesday, August 25, 2021 9:27 AM To: libffi-discuss@sourceware.org Subject: Re: is fork() supported? On 8/24/21 10:58 PM, Jay K via Libffi-discuss wrote: > I believe MacOSX also has this as an extension like this, in that > instead of giving an fd to map, you can give an address, to another > function, I cannot find the name. This can be used, I guess, to > avoid remapping the entire .so. Mac solves the problem in a much nicer way, one that is JIT-friendly but does not allow pages to be both W and X. Here's how it works: Call mmap with the MAP_JIT option to create a memory region for the new machine instructions. Call pthread_jit_write_protect_np() with the value false to disable JIT write protections for the memory region in the current thread. Write the machine instructions to the memory region. Note that this is *per thread*. other threads will simply continue to execute code in the JITted region. The JIT can generate code, but can not execute any JITted code until it calls pthread_jit_write_protect_np(true). Of course this requires threads to have differently-mapped regions. It would be very nice to have in Linux. It is the right way to do it. https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fdevelope= r.apple.com%2Fdocumentation%2Fapple-silicon%2Fporting-just-in-time-compiler= s-to-apple-silicon&data=3D04%7C01%7C%7C8e3a0f2a2e084358a7f708d967aa962f= %7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637654804622490592%7CUnknown%= 7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M= n0%3D%7C1000&sdata=3D%2FCuwk5zssydzfZqBgj9q%2BCt32dJ07Y8DyvEoRwZ2ZhI%3D= &reserved=3D0 -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fkeybase.= io%2Fandrewhaley&data=3D04%7C01%7C%7C8e3a0f2a2e084358a7f708d967aa962f%7= C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637654804622500585%7CUnknown%7C= TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0= %3D%7C1000&sdata=3D9h6U8eCdUgolrNdQgPDktROXmT2J1JMhchU4DJYAOyg%3D&r= eserved=3D0 EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671