From: Daniel Micay <danielmicay@gmail.com>
To: musl@lists.openwall.com
Cc: Daniel Micay <danielmicay@gmail.com>
Subject: [PATCH] prevent allocs than PTRDIFF_MAX via mremap
Date: Sat, 31 Oct 2015 05:14:45 -0400 [thread overview]
Message-ID: <1446282885-5290-1-git-send-email-danielmicay@gmail.com> (raw)
It's quite feasible for this to happen via MREMAP_MAYMOVE.
---
src/mman/mremap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/mman/mremap.c b/src/mman/mremap.c
index 596c45f..1096ace 100644
--- a/src/mman/mremap.c
+++ b/src/mman/mremap.c
@@ -1,5 +1,7 @@
#include <unistd.h>
#include <sys/mman.h>
+#include <errno.h>
+#include <stdint.h>
#include <stdarg.h>
#include "syscall.h"
#include "libc.h"
@@ -8,7 +10,12 @@ void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
{
va_list ap;
void *new_addr;
-
+
+ if (new_len >= PTRDIFF_MAX) {
+ errno = ENOMEM;
+ return MAP_FAILED;
+ }
+
va_start(ap, flags);
new_addr = va_arg(ap, void *);
va_end(ap);
--
2.6.2
next reply other threads:[~2015-10-31 9:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-31 9:14 Daniel Micay [this message]
2015-10-31 9:20 ` Daniel Micay
2015-10-31 20:30 ` Rich Felker
2015-11-02 21:46 ` Rich Felker
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=1446282885-5290-1-git-send-email-danielmicay@gmail.com \
--to=danielmicay@gmail.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).