News for hackers. Stuff that matters.
Re:Sandboxing Python with Win32 App Isolation by marwis on Thursday March 14, 2024 @11:10PM (#39711686)
I'm not an expert on the subject but just happen to know this was possible since XP: https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns...

See JOB_OBJECT_LIMIT_PROCESS_MEMORY and JOB_OBJECT_LIMIT_PROCESS_TIME.

Job is basically Windows equivalent of Linux Control Group.

Re:Sandboxing Python with Win32 App Isolation by dataflow on Friday March 15, 2024 @12:38AM (#39712114)
No, the CPU one isn't the same. It's a cumulative limit (resulting in termination when exceeded). The parent is asking for rate limits (resulting in throttling when exceeded).
Re:Sandboxing Python with Win32 App Isolation by marwis on Friday March 15, 2024 @12:55AM (#39712181)
It's not really clear from OP that it's about rate. Cumulative limit would still fulfill requirement of stopping while(true) from exhausting resources.

But if you need rate there's this: JOB_OBJECT_ CPU_RATE_CONTROL_MIN_MAX_RATE https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns...

Re:Sandboxing Python with Win32 App Isolation by dataflow on Friday March 15, 2024 @01:12AM (#39712253)
It's not explicitly written, but it's a pretty unavoidable conclusion.

As far as the verbiage goes -- "doesn't exhaust" means "uses less than the full amount available". Given that "total CPU time" isn't something you can run out of, "doesn't exhaust CPU" can only mean "uses less CPU than is currently available", i.e. "utilizes < 100% of the CPU", i.e. throttling.

As a practical matter, pretty much ~no user wants to kill a program after N seconds, and ~no program can limit itself to N seconds of work, either. People just want their CPU to have bandwidth to do other work, avoid heating up, etc. So unless you have a strong reason to believe otherwise, it's fair to assume people want to limit CPU utilization, not total CPU time.

Re:Sandboxing Python with Win32 App Isolation by mike_hearn on Friday March 15, 2024 @03:47AM (#39713051)
> pretty much ~no user wants to kill a program after N seconds

This is exactly how the web and cloud FaaS like AWS Lambda does it, so I don't think it's right to say nobody wants this. Runaway code does need to be killed.

Re:Sandboxing Python with Win32 App Isolation by dataflow on Friday March 15, 2024 @03:53AM (#39713081)
I didn't say nobody wants this, I said no user wants this. We're not talking web servers, we're talking about Windows desktop apps here... with humans using them. User != admin != owner. "Web and cloud FaaS like AWS Lambda" don't have "users" (i.e. the kind who would say "this shouldn't exhaust my system resources" like the parent did). They're cattle, running batch jobs, and/or serving APIs that other client applications invoke...
Re:Sandboxing Python with Win32 App Isolation by mike_hearn on Friday March 15, 2024 @05:12AM (#39713567)
Web pages have users (JS has time limited execution and will be killed if the page hangs).
Re:Sandboxing Python with Win32 App Isolation by dataflow on Friday March 15, 2024 @10:21AM (#39716061)
Are you under the impression web pages can access the Win32 API?