From: Rick Edgecombe <rick.p.edgecombe@intel.com>
To: kernel-hardening@lists.openwall.com, daniel@iogearbox.net,
keescook@chromium.org, catalin.marinas@arm.com,
will.deacon@arm.com, davem@davemloft.net, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, x86@kernel.org, arnd@arndb.de,
jeyu@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mips@linux-mips.org,
linux-s390@vger.kernel.org, sparclinux@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org
Cc: kristen@linux.intel.com, dave.hansen@intel.com,
arjan@linux.intel.com, deneen.t.dock@intel.com,
Rick Edgecombe <rick.p.edgecombe@intel.com>
Subject: [PATCH v2 3/7] arm/modules: Add rlimit checking for arm modules
Date: Thu, 11 Oct 2018 16:31:13 -0700 [thread overview]
Message-ID: <20181011233117.7883-4-rick.p.edgecombe@intel.com> (raw)
Message-ID: <20181011233113.RoYUHPRLamAtJHDoy3k3EzSg3v4mDojVmvY1j1gOVRI@z> (raw)
In-Reply-To: <20181011233117.7883-1-rick.p.edgecombe@intel.com>
This adds in the rlimit checking for the arm module allocator.
This has not been tested.
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
---
arch/arm/kernel/module.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 3ff571c2c71c..e331863553d2 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -43,6 +43,9 @@ void *module_alloc(unsigned long size)
gfp_t gfp_mask = GFP_KERNEL;
void *p;
+ if (check_inc_mod_rlimit(size))
+ return NULL;
+
/* Silence the initial allocation */
if (IS_ENABLED(CONFIG_ARM_MODULE_PLTS))
gfp_mask |= __GFP_NOWARN;
@@ -51,10 +54,15 @@ void *module_alloc(unsigned long size)
gfp_mask, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
__builtin_return_address(0));
if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p)
- return p;
- return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
+ goto done;
+ p = __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
__builtin_return_address(0));
+
+done:
+ update_mod_rlimit(p, size);
+
+ return p;
}
#endif
--
2.17.1
next prev parent reply other threads:[~2018-10-12 7:09 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 23:31 [PATCH v2 0/7] Rlimit for module space Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
2018-10-11 23:31 ` [PATCH v2 1/7] modules: Create rlimit " Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
2018-10-12 0:35 ` Jann Horn
2018-10-12 0:35 ` Jann Horn
2018-10-12 17:04 ` Edgecombe, Rick P
2018-10-12 17:04 ` Edgecombe, Rick P
2018-10-12 17:22 ` Jann Horn
2018-10-12 17:22 ` Jann Horn
2018-10-13 0:04 ` Edgecombe, Rick P
2018-10-13 0:04 ` Edgecombe, Rick P
2018-10-13 0:09 ` Jann Horn
2018-10-13 0:09 ` Jann Horn
2018-10-23 11:32 ` Michal Hocko
2018-10-23 11:32 ` Michal Hocko
2018-10-12 18:23 ` Jann Horn
2018-10-12 18:23 ` Jann Horn
2018-10-11 23:31 ` [PATCH v2 2/7] x86/modules: Add rlimit checking for x86 modules Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe [this message]
2018-10-11 23:31 ` [PATCH v2 3/7] arm/modules: Add rlimit checking for arm modules Rick Edgecombe
2018-10-11 23:31 ` [PATCH v2 4/7] arm64/modules: Add rlimit checking for arm64 modules Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
2018-10-11 23:47 ` Dave Hansen
2018-10-11 23:47 ` Dave Hansen
2018-10-12 14:32 ` Jessica Yu
2018-10-12 14:32 ` Jessica Yu
2018-10-12 22:01 ` Edgecombe, Rick P
2018-10-12 22:01 ` Edgecombe, Rick P
2018-10-12 22:54 ` Edgecombe, Rick P
2018-10-12 22:54 ` Edgecombe, Rick P
2018-10-11 23:31 ` [PATCH v2 5/7] mips/modules: Add rlimit checking for mips modules Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
2018-10-11 23:31 ` [PATCH v2 6/7] sparc/modules: Add rlimit for sparc modules Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
2018-10-11 23:31 ` [PATCH v2 7/7] s390/modules: Add rlimit checking for s390 modules Rick Edgecombe
2018-10-11 23:31 ` Rick Edgecombe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181011233117.7883-4-rick.p.edgecombe@intel.com \
--to=rick.p.edgecombe@intel.com \
--cc=arjan@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@intel.com \
--cc=davem@davemloft.net \
--cc=deneen.t.dock@intel.com \
--cc=jeyu@kernel.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=kristen@linux.intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-s390@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).