From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.windstream.net (mail.windstream.syn-alias.com [69.168.106.36]) by sourceware.org (Postfix) with ESMTPS id A07E83858020 for ; Fri, 12 Feb 2021 15:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A07E83858020 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=fexl.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=pc@fexl.com X_CMAE_Category: , , X-CNFS-Analysis: v=2.4 cv=MdKpB7zf c=1 sm=1 tr=0 ts=60269a8f cx=a_idp_x a=PDGaJ8dF8zRAWf39Bu4Cgw==:117 a=PDGaJ8dF8zRAWf39Bu4Cgw==:17 a=KGjhK52YXX0A:10 a=IkcTkHD0fZMA:10 a=qa6Q16uM49sA:10 a=Ehmfxr484HgA:10 a=w_pzkKWiAAAA:8 a=ASX2vHs3AAAA:8 a=PsnnGW_NAAAA:20 a=HfvydwfFgI27Mz5wwLwA:9 a=QEXdDO2ut3YA:10 a=sRI3_1zDfAgwuvI8zelB:22 a=hJFwQfz3FhWSUknangnR:22 X-CM-Score: 0 X-Scanned-by: Cloudmark Authority Engine X-Authed-Username: Y2hrb3JlZmZAd2luZHN0cmVhbS5uZXQ= Authentication-Results: smtp04.aqua.bos.sync.lan smtp.user=chkoreff@windstream.net; auth=pass (LOGIN) Received: from [40.138.173.84] ([40.138.173.84:50146] helo=[192.168.7.23]) by mail.windstream.net (envelope-from ) (ecelerity 3.6.25.56547 r(Core:3.6.25.0)) with ESMTPSA (cipher=AES128-SHA) id 67/C7-03297-E8A96206; Fri, 12 Feb 2021 10:11:11 -0500 Subject: Re: setrlimit always fails To: cygwin@cygwin.com References: <1c233bc7-401b-568f-36d5-48c4f1d4dcea@cornell.edu> From: Patrick Chkoreff Autocrypt: addr=pc@fexl.com; keydata= mQINBFVTu9wBEAD3HrqNmAU5TPesso2t7QG+bq/Y9Brz0X/9JIqPHT4eSiRCQmm228QFJfm8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rm0DEFhxLKRear+aq usmkvoQVNqMAEQEAAYkCPAQYAQgAJgIbDBYhBB4N3X/cPmRHVL+gVY/YYoGmqVZtBQJeugTn BQkPCeOLAAoJEI/YYoGmqVZtABsP/25z6bTxB5szwFOqdkSTpGlVeCqHxInsH60BeliBzr1p qAX6urpdMwNzCpRa9DroU7wwtOJ2z7FtCCdoDtnCaWRLqw2lqsZp7KeGOrCCHbSbpr/KXj2s wrN5AH69tSUN6yQlL3NdaD4go3VbjVNY2fFZkzi+ohlrVqaBZGPv/YaZhVnW29Z+bss2Emsp 3+x49RmOSXvSRHE4CsBbayIRIPwt4WvtbEzwquHn8Z3e7/4yBO43phaVkgP3YBR9Pv5dEYgr teBB0XtJ6DO08vmtMjvziXS6lcdj0cS+znoyyN8DLT8Na4LcEWeQaM6kZG3QoO4ZA17KPq1V hE2QPKNmfGcsTSZnz+I/RLyel0A75JzbcTXRKAnKGppZL5Mapgmk9MWyHdV+/LFDpvoNUkN4 mBpJ7CSeR59pJ8u7v8bHPnBR1w0TYySONrpN/46JdZj4IuKP9h+6K3j0dKFycKobhCT0Mdel 9Xj7W/jmScEA9+Vbg7quRy5ay5nRWh18STdLp1AHwyZZ+5XscdCHgtqu/jYecPxjB37ILfl7 mcDR+8yj4yHZEyFW+n8ai3+Lijea+KdjE0/7nWwYIJNs9TWwL2cOPURznPHdFWTg5qFUIils L55yRVFSzndW7wiYONMHRIWTF5kGLDeMTP357EDVsKRxAg0G2w2fQVKC5HD9L8N3 Message-ID: Date: Fri, 12 Feb 2021 10:11:09 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1c233bc7-401b-568f-36d5-48c4f1d4dcea@cornell.edu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Vade-Verditct: clean X-Vade-Analysis: gggruggvucftvghtrhhoucdtuddrgeduledriedugdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfujgfpteevqfftpdghkffpfffuvfftgfetofdpqfgfvfenuceurghilhhouhhtmecufedtudenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrrghtrhhitghkucevhhhkohhrvghffhcuoehptgesfhgvgihlrdgtohhmqeenucggtffrrghtthgvrhhnpeekleeuhfegieduledtfeekfefffedvjeegkedvffdukefhudfgtdeljefhteevueenucffohhmrghinheptgihghifihhnrdgtohhmpdhfvgiglhdrtghomhdpghhithhhuhgsrdgtohhmnecukfhppeegtddrudefkedrudejfedrkeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedtrddufeekrddujeefrdekgeenpdhmrghilhhfrhhomhepphgtsehfvgiglhdrtghomhenpdhrtghpthhtoheptgihghifihhnsegthihgfihinhdrtghomhen X-Vade-Client: WINDSTREAM X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2021 15:11:13 -0000 Ken Brown via Cygwin wrote on 2/11/21 9:06 PM: > Cygwin's setrlimit only supports a few resources, as you can see in the > source: > > https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/resource.cc;h=97777e9d223466b7635b990d6c9e0bfb9e2e9a46;hb=HEAD#l201 Thank you to all who replied. Shortly after I sent the email, I did some more searching and did find some posts to that effect, including one that said setrlimit was originally added as a stub to support porting OpenSSH. Also thank you for the pointer to the source code. The reason I'm asking about setrlimit is that I'm porting the code for my functional programming language "Fexl" from Linux to Windows under Cygwin. (https://fexl.com) In that language I have embedded functions limit_time, limit_stack, and limit_memory which call setrlimit. Those functions can be used to set sensible limits before running potentially dangerous code. It's safe enough to allow running a program entered by a stranger in a text area on a web site -- even a program which deliberately tries to use an unbounded amount of memory. I don't know if native Windows provides enough to flesh out setrlimit with the equivalent behavior on Linux, even for my very limited usage (RLIMIT_CPU, RLIMIT_STACK, RLIMIT_AS). Therefore the only way for me to do safe limits in Fexl would be to actually count evaluation steps in my evaluation loop, and memory usage in my allocation wrapper, and halt the program if it exceeds any user-imposed limits. So I would have to check evaluation steps here: https://github.com/chkoreff/Fexl/blob/956bdf85ff5046ebfa7fe582584fedc6881152db/src/value.c#L137 And check memory usage here: https://github.com/chkoreff/Fexl/blob/956bdf85ff5046ebfa7fe582584fedc6881152db/src/memory.c#L28 It's either that or deprecate my usage of setrlimit altogether, making it impossible to protect against runaway execution of potentially dangerous unvetted code. I will say that my first attempt at compiling the Linux code under Cygwin went very well. The only compiler error was in some code that calls strptime. To fix that, I had to use some macros in a sequence like this: #ifdef __CYGWIN__ /* Ensure that strptime is accessible. */ #define _XOPEN_SOURCE #endif #include ... #ifndef __CYGWIN__ /* Ensure that strptime is accessible. */ #define __USE_XOPEN #endif #include That seems to be the simplest I can make that. Thank you to all the Cygwin developers who made this porting effort possible! -- Patrick