delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
DMARC-Filter: | OpenDMARC Filter v1.4.1 sourceware.org 414733888838 |
Authentication-Results: | sourceware.org; |
dmarc=none (p=none dis=none) header.from=orange.fr | |
Authentication-Results: | sourceware.org; spf=pass smtp.mailfrom=orange.fr |
X-ME-Helo: | cohn |
X-ME-Auth: | ZWxpZ2lzQHdhbmFkb28uZnI= |
X-ME-Date: | Sat, 12 Nov 2022 12:28:56 +0100 |
X-ME-IP: | 193.248.180.53 |
From: | "Christian Jullien" <eligis AT orange DOT fr> |
To: | <cygwin AT cygwin DOT com> |
Subject: | Is there an API to remove ALSR in Cygwin 3.4.0? |
Date: | Sat, 12 Nov 2022 12:28:55 +0100 |
Organization: | Eligis |
Message-ID: | <000501d8f689$f359a300$da0ce900$@orange.fr> |
MIME-Version: | 1.0 |
X-Mailer: | Microsoft Outlook 14.0 |
Thread-Index: | Adj2ifLOsQnMc2IiQ3ebs2uldwUoIg== |
X-Spam-Status: | No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_FROM, |
HTML_MESSAGE, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, | |
RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, | |
TXREP autolearn=no autolearn_force=no version=3.4.6 | |
X-Spam-Checker-Version: | SpamAssassin 3.4.6 (2021-04-09) on |
server2.sourceware.org | |
X-Content-Filtered-By: | Mailman/MimeDel 2.1.29 |
X-BeenThere: | cygwin AT cygwin DOT com |
X-Mailman-Version: | 2.1.29 |
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
Reply-To: | jullien AT eligis DOT com |
Sender: | "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com> |
Hello Cygwin team, First, I would like to thank you for your efforts on Cygwin all of these years. I'm asking if there will be an API to remove ASLR with an API as on Linux: #if defined(__linux__) /* * ADDR_NO_RANDOMIZE exists since Linux 2.6.12 * With this flag set, disable address-space-layout randomization. * * Not tested but gcc could remove ALSR with the following flags: * gcc -fno-stack-protector -z execstack -no-pie ... */ const int oldpersonality = personality(ADDR_NO_RANDOMIZE); /* * It's important to use non-zero-ness of & ADDR_NO_RANDOMIZE * and not equality tests other we may go to infinite loop * with execv. */ if (!(oldpersonality & ADDR_NO_RANDOMIZE)) { /* * ASLR has been asked by first personality call but an error * may have been returned. Call personality a second time * to verify it has really been removed. */ const int newpersonality = personality(ADDR_NO_RANDOMIZE); if (newpersonality & ADDR_NO_RANDOMIZE) { execv(argv[0], argv); } } #endif Or as on macOS: if (spawned == 0) { short ps_flags = 0; pid_t pid; posix_spawn_file_actions_t actions; posix_spawnattr_t attrs; cargv[cargc++] = (char *)"--noaslr"; cargv[cargc] = NULL; (void)posix_spawn_file_actions_init(&actions); (void)posix_spawnattr_init(&attrs); ps_flags |= POSIX_SPAWN_SETEXEC; ps_flags |= _POSIX_SPAWN_DISABLE_ASLR; ret = posix_spawnattr_setflags(&attrs, ps_flags); if (ret != 0) { (void)fprintf(stderr, "%s: cannot set posix_spawn flags.\n", argv[0]); free(cargv); return ret; } (void)posix_spawnp(&pid, cargv[0], &actions, &attrs, cargv, envp); /* * returns only if posix_spawnp fails. */ (void)posix_spawnattr_destroy(&attrs); } Allowing to remove ALSR with an API, allows an application to decide what to do (from command line for example: ./myapp --no-alsr --save-core saved-image.cor; ./myapp --no-alsr --use-core saved-image.cor) My preference goes to personality support the way it is done on Linux. If a gcc flag already exists, it will force a mode instead of leaving this option to end user. My Lisp (OpenLisp) has an optional feature name 'execore' which combines lisp binary and a saved image into a single executable which fails to run of course if ALSR is on. For me, it's a wish not a strong request. Christian -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |