From a20a372b0f97a5fa935ddc538b4f472c6b2ce4f7 Mon Sep 17 00:00:00 2001
From: Owen <owenca@users.noreply.github.com>
Date: Mon, 4 Dec 2017 03:39:51 +0000
Subject: [PATCH 3/3] Implement setrlimit() for RLIMIT_AS, RLIMIT_DATA, and
RLIMIT_STACK
Fixes #3353
---
src/system/kernel/thread.cpp | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp
index 12203f0..bee753e 100644
a
|
b
|
common_setrlimit(int resource, const struct rlimit * rlp)
|
1348 | 1348 | return B_BAD_ADDRESS; |
1349 | 1349 | |
1350 | 1350 | switch (resource) { |
| 1351 | case RLIMIT_AS: |
| 1352 | if (rlp->rlim_cur != __HAIKU_ADDR_MAX |
| 1353 | || rlp->rlim_max != __HAIKU_ADDR_MAX) |
| 1354 | return EINVAL; |
| 1355 | return B_OK; |
| 1356 | |
1351 | 1357 | case RLIMIT_CORE: |
1352 | 1358 | // We don't support core file, so allow settings to 0/0 only. |
1353 | 1359 | if (rlp->rlim_cur != 0 || rlp->rlim_max != 0) |
1354 | 1360 | return EINVAL; |
1355 | 1361 | return B_OK; |
1356 | 1362 | |
| 1363 | case RLIMIT_DATA: |
| 1364 | if (rlp->rlim_cur != RLIM_INFINITY |
| 1365 | || rlp->rlim_max != RLIM_INFINITY) |
| 1366 | return EINVAL; |
| 1367 | return B_OK; |
| 1368 | |
1357 | 1369 | case RLIMIT_NOFILE: |
1358 | 1370 | case RLIMIT_NOVMON: |
1359 | 1371 | return vfs_setrlimit(resource, rlp); |
1360 | 1372 | |
| 1373 | case RLIMIT_STACK: |
| 1374 | if (rlp->rlim_cur != USER_MAIN_THREAD_STACK_SIZE |
| 1375 | || rlp->rlim_max != USER_MAIN_THREAD_STACK_SIZE) |
| 1376 | return EINVAL; |
| 1377 | return B_OK; |
| 1378 | |
1361 | 1379 | default: |
1362 | 1380 | return EINVAL; |
1363 | 1381 | } |