strace sys_clone bug on x86-32

enh enh at google.com
Thu Apr 10 01:19:20 UTC 2014


i don't think

commit f94e84780e96221a4b3e8eb39bfa2d227d367f69
Author: Dmitry V. Levin <ldv at altlinux.org>
Date:   Wed Apr 9 12:30:38 2014 +0000

    x32: decode clone LDT user_desc entries for x86 processes

    * mem.c [X32]: Include asm/ldt.h.
    [X32] (print_ldt_entry, sys_modify_ldt, sys_set_thread_area,
    sys_get_thread_area): Define.
    * process.c [X32]: Include asm/ldt.h.
    (sys_clone) [X32]: Decode LDT entry if current_personality == 1.

builds for I386, because there's a dangling 'else'. that's why my
version had the "int print_raw_tls = 1;" --- so we can rewrite the
'else', which now means "if (process has x86_64 personality or (it's
one of the other personalities but the umove failed))".

suggested fix: https://android-review.googlesource.com/90614

commit c958e1c4e85334042d5ee1a90bfa4b8101d177d3
Author: Elliott Hughes <enh at google.com>
Date:   Wed Apr 9 18:14:34 2014 -0700

    Fix dangling else in x86 build.

    Change-Id: Id4ee2f8baab9d765a06a9114de4bce79177e0e3d
    Signed-off-by: Elliott Hughes <enh at google.com>

diff --git a/process.c b/process.c
index 963d3b1..0bac367 100644
--- a/process.c
+++ b/process.c
@@ -556,6 +556,7 @@ sys_clone(struct tcb *tcp)
  if (flags & CLONE_PARENT_SETTID)
  tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
  if (flags & CLONE_SETTLS) {
+ int print_raw_tls = 1;
 #if defined I386 || defined X86_64 || defined X32
 # ifndef I386
  if (current_personality == 1)
@@ -569,10 +570,11 @@ sys_clone(struct tcb *tcp)
  tprints("...}");
  else
  print_ldt_entry(&copy);
+ print_raw_tls = 0;
  }
  }
- else
 #endif /* I386 || X86_64 || X32 */
+ if (print_raw_tls)
  tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
  }
  if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))


alternatively, you could have another #ifdef:
https://android-review.googlesource.com/90630

commit 463302b46258b3c2c205ea6b92336debef24a8fc
Author: Elliott Hughes <enh at google.com>
Date:   Wed Apr 9 18:17:46 2014 -0700

    Fix dangling else in x86 build.

    Change-Id: Ia8c27a239fd64936dec5f31f88ef40154b128323
    Signed-off-by: Elliott Hughes <enh at google.com>

diff --git a/process.c b/process.c
index 963d3b1..fc2a3d7 100644
--- a/process.c
+++ b/process.c
@@ -571,7 +571,9 @@ sys_clone(struct tcb *tcp)
  print_ldt_entry(&copy);
  }
  }
+# ifndef I386
  else
+# endif
 #endif /* I386 || X86_64 || X32 */
  tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
  }


On Wed, Apr 9, 2014 at 7:20 AM, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Sun, Apr 06, 2014 at 12:41:17PM -0700, enh wrote:
>>     Fix clone(2) argument order for 32-bit processes on x86-64.
> [...]
>> if you want to get fancy, you can also decode the LDT user_desc
>> entries (like you would if you were using an x86 strace to trace an
>> x86 process):
>
> Thanks, applied both patches, and added the same change for X32.
>
>
> --
> ldv
>
> ------------------------------------------------------------------------------
> Put Bad Developers to Shame
> Dominate Development with Jenkins Continuous Integration
> Continuously Automate Build, Test & Deployment
> Start a new project now. Try Jenkins in the cloud.
> http://p.sf.net/sfu/13600_Cloudbees
> _______________________________________________
> Strace-devel mailing list
> Strace-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Java i18n/JNI/NIO, or bionic questions? Mail me/drop by/add me as a reviewer.
-------------- next part --------------
commit c958e1c4e85334042d5ee1a90bfa4b8101d177d3
Author: Elliott Hughes <enh at google.com>
Date:   Wed Apr 9 18:14:34 2014 -0700

    Fix dangling else in x86 build.
    
    Change-Id: Id4ee2f8baab9d765a06a9114de4bce79177e0e3d
    Signed-off-by: Elliott Hughes <enh at google.com>

diff --git a/process.c b/process.c
index 963d3b1..0bac367 100644
--- a/process.c
+++ b/process.c
@@ -556,6 +556,7 @@ sys_clone(struct tcb *tcp)
 		if (flags & CLONE_PARENT_SETTID)
 			tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
 		if (flags & CLONE_SETTLS) {
+			int print_raw_tls = 1;
 #if defined I386 || defined X86_64 || defined X32
 # ifndef I386
 			if (current_personality == 1)
@@ -569,10 +570,11 @@ sys_clone(struct tcb *tcp)
 						tprints("...}");
 					else
 						print_ldt_entry(&copy);
+					print_raw_tls = 0;
 				}
 			}
-			else
 #endif /* I386 || X86_64 || X32 */
+			if (print_raw_tls)
 				tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
 		}
 		if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
-------------- next part --------------
commit 463302b46258b3c2c205ea6b92336debef24a8fc
Author: Elliott Hughes <enh at google.com>
Date:   Wed Apr 9 18:17:46 2014 -0700

    Fix dangling else in x86 build.
    
    Change-Id: Ia8c27a239fd64936dec5f31f88ef40154b128323
    Signed-off-by: Elliott Hughes <enh at google.com>

diff --git a/process.c b/process.c
index 963d3b1..fc2a3d7 100644
--- a/process.c
+++ b/process.c
@@ -571,7 +571,9 @@ sys_clone(struct tcb *tcp)
 						print_ldt_entry(&copy);
 				}
 			}
+# ifndef I386
 			else
+# endif
 #endif /* I386 || X86_64 || X32 */
 				tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
 		}


More information about the Strace-devel mailing list