public inbox for trinity@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix to broken random selection of syscalls.
@ 2013-10-04 18:29 Ildar Muslukhov
  2013-10-07 23:04 ` Ildar Muslukhov
  0 siblings, 1 reply; 3+ messages in thread
From: Ildar Muslukhov @ 2013-10-04 18:29 UTC (permalink / raw)
  To: trinity; +Cc: davej


This patch fixes random selection of system calls, introduced in the 
earlier commit.

Signed-off-by: Ildar Muslukhov <ildarm@google.com>

---
 tables.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tables.c b/tables.c
index f41ffac..618d742 100644
--- a/tables.c
+++ b/tables.c
@@ -15,6 +15,8 @@
 #include "log.h"
 #include "shm.h"
 
+#define NOTFOUND (unsigned int)-1
+
 const struct syscalltable *syscalls;
 const struct syscalltable *syscalls_32bit;
 const struct syscalltable *syscalls_64bit;
@@ -813,9 +815,7 @@ void disable_non_net_syscalls(void)
 void enable_random_syscalls(void)
 {
 	unsigned int i;
-	unsigned int call, call32, call64, callnotfound;
-
-	callnotfound = (unsigned int)-1;
+	unsigned int call, call32, call64;
 
 	if (random_selection_num == 0) {
 		printf("-r 0 syscalls ? what?\n");
@@ -840,8 +840,8 @@ void enable_random_syscalls(void)
 
 retry:
 		if (biarch == TRUE) {
-			call64 = callnotfound;
-			call32 = callnotfound;
+			call64 = NOTFOUND;
+			call32 = NOTFOUND;
 
 			//Search for 64 bit version
 			if (do_64_arch) {
@@ -853,11 +853,11 @@ retry:
 					if (is_syscall_net_related(syscalls_64bit, call64) == FALSE)
 						goto retry;
 
-				if (syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED)
+				if ((syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED) || (syscalls_64bit[call64].entry->active_number != 0))
 					goto try32bit;
 
 				//If we got so far, then active it.
-				toggle_syscall_biarch_n(i, syscalls_64bit, TRUE, do_64_arch, TRUE,
+				toggle_syscall_biarch_n(call64, syscalls_64bit, TRUE, do_64_arch, TRUE,
 							&activate_syscall64, 64, syscalls_64bit[call64].entry->name);
 			}
 try32bit:
@@ -867,35 +867,35 @@ try32bit:
 				if (do_64_arch) {
 					call32 = search_syscall_table(syscalls_32bit, max_nr_32bit_syscalls, syscalls_64bit[call64].entry->name);
 					if (syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED)
-						call64 = callnotfound; //mark as not found in order not to increment i.
+						call64 = NOTFOUND; //mark as not found in order not to increment i.
 				} else {
 					call32 = rand() % max_nr_32bit_syscalls;
 				}
 
 				if (validate_specific_syscall_silent(syscalls_32bit, call32) == FALSE) {
-					if (call64 == callnotfound)
+					if (call64 == NOTFOUND)
 						goto retry;
 					else
 						continue;
 				}
 
 				if (no_files == TRUE)
-					if (is_syscall_net_related(syscalls_64bit, call64) == FALSE) {
-						if (call64 == callnotfound)
+					if (is_syscall_net_related(syscalls_32bit, call32) == FALSE) {
+						if (call64 == NOTFOUND)
 							goto retry;
 						else
 							continue;
 					}
 
-				if (syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED) {
-					if (call64 == callnotfound)
+				if ((syscalls_32bit[call32].entry->flags & TO_BE_DEACTIVATED) || (syscalls_32bit[call32].entry->active_number != 0)) {
+					if (call64 == NOTFOUND)
 						goto retry;
 					else
 						continue;
 				}
 
 				//If we got so far, then active it.
-				toggle_syscall_biarch_n(i, syscalls_32bit, TRUE, do_32_arch, TRUE,
+				toggle_syscall_biarch_n(call32, syscalls_32bit, TRUE, do_32_arch, TRUE,
 							&activate_syscall32, 32, syscalls_32bit[call32].entry->name);
 			}
 
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix to broken random selection of syscalls.
  2013-10-04 18:29 [PATCH] Fix to broken random selection of syscalls Ildar Muslukhov
@ 2013-10-07 23:04 ` Ildar Muslukhov
  2013-10-07 23:16   ` Dave Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Ildar Muslukhov @ 2013-10-07 23:04 UTC (permalink / raw)
  To: trinity; +Cc: Dave Jones

Any news on that one?

On Fri, Oct 4, 2013 at 11:29 AM, Ildar Muslukhov <ildarm@google.com> wrote:
>
> This patch fixes random selection of system calls, introduced in the
> earlier commit.
>
> Signed-off-by: Ildar Muslukhov <ildarm@google.com>
>
> ---
>  tables.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/tables.c b/tables.c
> index f41ffac..618d742 100644
> --- a/tables.c
> +++ b/tables.c
> @@ -15,6 +15,8 @@
>  #include "log.h"
>  #include "shm.h"
>
> +#define NOTFOUND (unsigned int)-1
> +
>  const struct syscalltable *syscalls;
>  const struct syscalltable *syscalls_32bit;
>  const struct syscalltable *syscalls_64bit;
> @@ -813,9 +815,7 @@ void disable_non_net_syscalls(void)
>  void enable_random_syscalls(void)
>  {
>         unsigned int i;
> -       unsigned int call, call32, call64, callnotfound;
> -
> -       callnotfound = (unsigned int)-1;
> +       unsigned int call, call32, call64;
>
>         if (random_selection_num == 0) {
>                 printf("-r 0 syscalls ? what?\n");
> @@ -840,8 +840,8 @@ void enable_random_syscalls(void)
>
>  retry:
>                 if (biarch == TRUE) {
> -                       call64 = callnotfound;
> -                       call32 = callnotfound;
> +                       call64 = NOTFOUND;
> +                       call32 = NOTFOUND;
>
>                         //Search for 64 bit version
>                         if (do_64_arch) {
> @@ -853,11 +853,11 @@ retry:
>                                         if (is_syscall_net_related(syscalls_64bit, call64) == FALSE)
>                                                 goto retry;
>
> -                               if (syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED)
> +                               if ((syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED) || (syscalls_64bit[call64].entry->active_number != 0))
>                                         goto try32bit;
>
>                                 //If we got so far, then active it.
> -                               toggle_syscall_biarch_n(i, syscalls_64bit, TRUE, do_64_arch, TRUE,
> +                               toggle_syscall_biarch_n(call64, syscalls_64bit, TRUE, do_64_arch, TRUE,
>                                                         &activate_syscall64, 64, syscalls_64bit[call64].entry->name);
>                         }
>  try32bit:
> @@ -867,35 +867,35 @@ try32bit:
>                                 if (do_64_arch) {
>                                         call32 = search_syscall_table(syscalls_32bit, max_nr_32bit_syscalls, syscalls_64bit[call64].entry->name);
>                                         if (syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED)
> -                                               call64 = callnotfound; //mark as not found in order not to increment i.
> +                                               call64 = NOTFOUND; //mark as not found in order not to increment i.
>                                 } else {
>                                         call32 = rand() % max_nr_32bit_syscalls;
>                                 }
>
>                                 if (validate_specific_syscall_silent(syscalls_32bit, call32) == FALSE) {
> -                                       if (call64 == callnotfound)
> +                                       if (call64 == NOTFOUND)
>                                                 goto retry;
>                                         else
>                                                 continue;
>                                 }
>
>                                 if (no_files == TRUE)
> -                                       if (is_syscall_net_related(syscalls_64bit, call64) == FALSE) {
> -                                               if (call64 == callnotfound)
> +                                       if (is_syscall_net_related(syscalls_32bit, call32) == FALSE) {
> +                                               if (call64 == NOTFOUND)
>                                                         goto retry;
>                                                 else
>                                                         continue;
>                                         }
>
> -                               if (syscalls_64bit[call64].entry->flags & TO_BE_DEACTIVATED) {
> -                                       if (call64 == callnotfound)
> +                               if ((syscalls_32bit[call32].entry->flags & TO_BE_DEACTIVATED) || (syscalls_32bit[call32].entry->active_number != 0)) {
> +                                       if (call64 == NOTFOUND)
>                                                 goto retry;
>                                         else
>                                                 continue;
>                                 }
>
>                                 //If we got so far, then active it.
> -                               toggle_syscall_biarch_n(i, syscalls_32bit, TRUE, do_32_arch, TRUE,
> +                               toggle_syscall_biarch_n(call32, syscalls_32bit, TRUE, do_32_arch, TRUE,
>                                                         &activate_syscall32, 32, syscalls_32bit[call32].entry->name);
>                         }
>
> --
> 1.8.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix to broken random selection of syscalls.
  2013-10-07 23:04 ` Ildar Muslukhov
@ 2013-10-07 23:16   ` Dave Jones
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Jones @ 2013-10-07 23:16 UTC (permalink / raw)
  To: Ildar Muslukhov; +Cc: trinity

On Mon, Oct 07, 2013 at 04:04:21PM -0700, Ildar Muslukhov wrote:
 > Any news on that one?

applied and pushed out, sorry for the delay, been sick.

	Dave

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-07 23:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-04 18:29 [PATCH] Fix to broken random selection of syscalls Ildar Muslukhov
2013-10-07 23:04 ` Ildar Muslukhov
2013-10-07 23:16   ` Dave Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox