Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 177f5b18 authored by Carlos Galo's avatar Carlos Galo Committed by Gerrit Code Review
Browse files

Merge "Set memlock rlimit to 64KB"

parents 60305abf 1447120f
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -21,8 +21,10 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android/api-level.h>
#include <gtest/gtest.h>
#include <selinux/selinux.h>
#include <sys/resource.h>

#include "action.h"
#include "action_manager.h"
@@ -626,6 +628,20 @@ service A something
    ASSERT_EQ(1u, parser.parse_error_count());
}

TEST(init, MemLockLimit) {
    // Test is enforced only for U+ devices
    if (android::base::GetIntProperty("ro.vendor.api_level", 0) < __ANDROID_API_U__) {
        GTEST_SKIP();
    }

    // Verify we are running memlock at, or under, 64KB
    const unsigned long max_limit = 65536;
    struct rlimit curr_limit;
    ASSERT_EQ(getrlimit(RLIMIT_MEMLOCK, &curr_limit), 0);
    ASSERT_LE(curr_limit.rlim_cur, max_limit);
    ASSERT_LE(curr_limit.rlim_max, max_limit);
}

class TestCaseLogger : public ::testing::EmptyTestEventListener {
    void OnTestStart(const ::testing::TestInfo& test_info) override {
#ifdef __ANDROID__
+3 −0
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ on early-init
    # Allow up to 32K FDs per process
    setrlimit nofile 32768 32768

    # set RLIMIT_MEMLOCK to 64KB
    setrlimit memlock 65536 65536

    # Set up linker config subdirectories based on mount namespaces
    mkdir /linkerconfig/bootstrap 0755
    mkdir /linkerconfig/default 0755