From: Matt Chapman <matthewc@cse.unsw.edu.au>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] mremap and "negative" addresses
Date: Fri, 01 Nov 2002 08:08:10 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590709805322@msgid-missing> (raw)
mremap, like mmap, can return addresses in region 4 which
are "negative" (when interpreted as signed values) and thus
interpreted as syscall failure. The following patch
implements the same workaround as for mmap and other such
syscalls.
(It looks like 2.5 also has the same issue, if this seems
sensible I can produce a patch for that as well.)
Matt
diff -ru linux-2.4.19-020821.orig/arch/ia64/kernel/entry.S linux-2.4.19-020821/arch/ia64/kernel/entry.S
--- linux-2.4.19-020821.orig/arch/ia64/kernel/entry.S 2002-09-17 16:18:06.000000000 +1000
+++ linux-2.4.19-020821/arch/ia64/kernel/entry.S 2002-11-01 15:11:50.000000000 +1100
@@ -1109,7 +1109,7 @@
data8 sys_mlock
data8 sys_mlockall
data8 sys_mprotect // 1155
- data8 sys_mremap
+ data8 ia64_mremap
data8 sys_msync
data8 sys_munlock
data8 sys_munlockall
diff -ru linux-2.4.19-020821.orig/arch/ia64/kernel/sys_ia64.c linux-2.4.19-020821/arch/ia64/kernel/sys_ia64.c
--- linux-2.4.19-020821.orig/arch/ia64/kernel/sys_ia64.c 2002-09-17 16:18:06.000000000 +1000
+++ linux-2.4.19-020821/arch/ia64/kernel/sys_ia64.c 2002-11-01 18:36:10.000000000 +1100
@@ -253,6 +253,21 @@
return addr;
}
+asmlinkage unsigned long
+ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags,
+ unsigned long new_addr, long arg5, long arg6, long arg7, long stack)
+{
+ struct pt_regs *regs = (struct pt_regs *) &stack;
+
+ down_write(¤t->mm->mmap_sem);
+ addr = do_mremap(addr, old_len, new_len, flags, new_addr);
+ up_write(¤t->mm->mmap_sem);
+
+ if (!IS_ERR((void *) addr))
+ regs->r8 = 0; /* ensure large addresses are not mistaken as failures... */
+ return addr;
+}
+
asmlinkage long
sys_vm86 (long arg0, long arg1, long arg2, long arg3)
{
diff -ru linux-2.4.19-020821.orig/include/linux/mm.h linux-2.4.19-020821/include/linux/mm.h
--- linux-2.4.19-020821.orig/include/linux/mm.h 2002-09-17 16:18:07.000000000 +1000
+++ linux-2.4.19-020821/include/linux/mm.h 2002-11-01 18:34:15.000000000 +1100
@@ -559,8 +559,10 @@
}
extern int do_munmap(struct mm_struct *, unsigned long, size_t);
-
extern unsigned long do_brk(unsigned long, unsigned long);
+extern unsigned long do_mremap(unsigned long addr,
+ unsigned long old_len, unsigned long new_len,
+ unsigned long flags, unsigned long new_addr);
static inline void __vma_unlink(struct mm_struct * mm, struct vm_area_struct * vma, struct vm_area_struct * prev)
{
next reply other threads:[~2002-11-01 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-01 8:08 Matt Chapman [this message]
2002-11-01 12:21 ` [Linux-ia64] mremap and "negative" addresses Matthew Wilcox
2002-11-01 12:58 ` David Mosberger
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=marc-linux-ia64-105590709805322@msgid-missing \
--to=matthewc@cse.unsw.edu.au \
--cc=linux-ia64@vger.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