Ticket #3353: 0002-Implement-setrlimit-for-RLIMIT_AS-RLIMIT_DATA-and-RL.patch

File 0002-Implement-setrlimit-for-RLIMIT_AS-RLIMIT_DATA-and-RL.patch, 1.4 KB (added by owenca, 7 years ago)
  • src/system/kernel/thread.cpp

    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)  
    13481348        return B_BAD_ADDRESS;
    13491349
    13501350    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
    13511357        case RLIMIT_CORE:
    13521358            // We don't support core file, so allow settings to 0/0 only.
    13531359            if (rlp->rlim_cur != 0 || rlp->rlim_max != 0)
    13541360                return EINVAL;
    13551361            return B_OK;
    13561362
     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
    13571369        case RLIMIT_NOFILE:
    13581370        case RLIMIT_NOVMON:
    13591371            return vfs_setrlimit(resource, rlp);
    13601372
     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
    13611379        default:
    13621380            return EINVAL;
    13631381    }