Trinity fuzzer tool discussions
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Vinson Lee <vlee@freedesktop.org>
Cc: trinity@vger.kernel.org, Vinson Lee <vlee@twitter.com>
Subject: Re: [PATCH] syscall/prctl.c: Fix unused variable build error with USE_SECCOMP=0.
Date: Wed, 4 Dec 2013 13:44:15 -0500	[thread overview]
Message-ID: <20131204184415.GA6013@redhat.com> (raw)
In-Reply-To: <1386181980-3294-1-git-send-email-vlee@freedesktop.org>

On Wed, Dec 04, 2013 at 10:33:00AM -0800, Vinson Lee wrote:
 > From: Vinson Lee <vlee@twitter.com>
 > 
 > This patch fixes this build error on CentOS 6.
 > 
 >   CC	syscalls/prctl.o
 > cc1: warnings being treated as errors
 > syscalls/prctl.c: In function ‘sanitise_prctl’:
 > syscalls/prctl.c:36: error: unused variable ‘saddr’
 > 
 > Signed-off-by: Vinson Lee <vlee@twitter.com>

bigger diff, but I think this looks cleaner..
Can you test ?


diff --git a/syscalls/prctl.c b/syscalls/prctl.c
index acca0279acab..09364df6a37a 100644
--- a/syscalls/prctl.c
+++ b/syscalls/prctl.c
@@ -17,6 +17,7 @@
 #include "maps.h"
 #include "shm.h"
 #include "compat.h"
+#include "trinity.h"
 
 #define NR_PRCTL_OPTS 28
 static int prctl_opts[NR_PRCTL_OPTS] = {
@@ -29,31 +30,39 @@ static int prctl_opts[NR_PRCTL_OPTS] = {
 	PR_MCE_KILL, PR_MCE_KILL_GET,
 };
 
+
+#ifdef USE_SECCOMP
+static void do_set_seccomp(int childno)
+{
+	struct sockaddr *saddr = NULL;
+
+//	if (rand() % 3 == SECCOMP_MODE_FILTER) {
+
+// FIXME: This leaks memory, but needs to be cleared after the syscall is done.
+		gen_seccomp_bpf((unsigned long **) &saddr, NULL);
+		shm->a2[childno] = SECCOMP_MODE_FILTER;
+		shm->a3[childno] = (unsigned long) saddr;
+//	}
+}
+#else
+static void do_set_seccomp(__unused__ int childno) { }
+#endif
+
 /* We already got a generic_sanitise at this point */
 void sanitise_prctl(int childno)
 {
 	int option = prctl_opts[rand() % NR_PRCTL_OPTS];
-	struct sockaddr *saddr = NULL;
 
 // For now, just do SECCOMP, the other options need some attention.
-option = PR_SET_SECCOMP;
+	option = PR_SET_SECCOMP;
 
-	/* Also allow crap by small chance */
-	if (rand() % 100 != 0)
-		shm->a1[childno] = option;
+	shm->a1[childno] = option;
 
 	switch (option) {
 	case PR_SET_SECCOMP:
-#ifdef USE_SECCOMP
-//		if (rand() % 3 == SECCOMP_MODE_FILTER) {
-// FIXME: This leaks memory, but needs to be cleared
-// after the syscall is done.
-			gen_seccomp_bpf((unsigned long **) &saddr, NULL);
-			shm->a2[childno] = SECCOMP_MODE_FILTER;
-			shm->a3[childno] = (unsigned long) saddr;
-//		}
-#endif
+		do_set_seccomp(childno);
 		break;
+
 	default:
 		break;
 	}

  reply	other threads:[~2013-12-04 18:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04 18:33 [PATCH] syscall/prctl.c: Fix unused variable build error with USE_SECCOMP=0 Vinson Lee
2013-12-04 18:44 ` Dave Jones [this message]
2013-12-04 18:49   ` Vinson Lee

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=20131204184415.GA6013@redhat.com \
    --to=davej@redhat.com \
    --cc=trinity@vger.kernel.org \
    --cc=vlee@freedesktop.org \
    --cc=vlee@twitter.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox