Skip to contentSkip to conversation

Resend: linux-user/syscall.c - don't add GUEST_BASE to NULL pointer

PATCH In review Jan-Simon Möller 2 participants 3 messages Oct 16, 2009 – Oct 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Resend: linux-user/syscall.c - don't add GUEST_BASE to NULL pointer

This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 .
failing call:
mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address)

correct call:
mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) = 0

---
 linux-user/syscall.c |    8 ++++++--

 1 files changed, 6 insertions(+), 2 deletions(-)
linux-user/syscall.c +0 -0
index 673eed4..5b2ec4f 100644
@@ -4445,12 +4445,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 

arg1,
                        p3 = lock_user_string(arg3);
                         if (!p || !p2 || !p3)
                             ret = -TARGET_EFAULT;
-                        else
+                        else {
                             /* FIXME - arg5 should be locked, but it isn't clear how to
                              * do that since it's not guaranteed to be a NULL-terminated
                              * string.
                              */
-                            ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+                            if ( ! arg5 )
+                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL));
+                            else
+                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+                        }
                         unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0);

#1 lore raw
Quoted 8 lines · Jan-Simon Möller

This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 .
failing call:
mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address)

correct call:
mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) = 0

The patch looks functionally correct, but your mailer has mangled it.

Quoted 35 lines

---
 linux-user/syscall.c |    8 ++++++--

 1 files changed, 6 insertions(+), 2 deletions(-)
linux-user/syscall.c +1 -1
index 673eed4..5b2ec4f 100644
@@ -4445,12 +4445,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
 arg1,
                         p3 = lock_user_string(arg3);
                          if (!p || !p2 || !p3)
                              ret = -TARGET_EFAULT;
-                        else
+                        else {
                              /* FIXME - arg5 should be locked, but it isn't 

clear how to
                              * do that since it's not guaranteed to be a NULL-terminated
                              * string.
                              */
-                            ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+                            if ( ! arg5 )
+                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL));
+                            else
+                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+                        }
                         unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0);

#2 lore raw

This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 . failing call:
mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address)

correct call:
mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) = 0

---
 linux-user/syscall.c |    8 ++++++--

 1 files changed, 6 insertions(+), 2 deletions(-)
linux-user/syscall.c +0 -0
index 673eed4..5b2ec4f 100644
@@ -4445,12 +4445,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,

                        p3 = lock_user_string(arg3);
                         if (!p || !p2 || !p3)
                             ret = -TARGET_EFAULT;
-                        else
+                        else {
                             /* FIXME - arg5 should be locked, but it isn't clear how to
                              * do that since it's not guaranteed to be a NULL-terminated
                              * string.
                              */
-                            ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+                            if ( ! arg5 )
+                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL));
+                            else
+                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+                        }
                         unlock_user(p, arg1, 0);
                         unlock_user(p2, arg2, 0);
                         unlock_user(p3, arg3, 0);