Skip to contentSkip to conversation

Wrapper for Syzkaller reproducers

PATCH Superseded Richard Palethorpe 6 participants 10 messages Jun 9, 2020 – Jun 15, 2020

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Allows one to run the Syzkaller reproducers as part of the LTP.

---

So this has now being floating in limbo for some time. My preference is to merge it to make it easy for users to try out with plenty of time before the next LTP release. It shouldn't break anything because it is hidden behind a configure switch.

V3:
+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

 .gitmodules                                  |   4 +
 configure.ac                                 |  12 ++
 include/mk/features.mk.in                    |   2 +
 runtest/.gitignore                           |   1 +
 testcases/kernel/Makefile                    |   1 +
 testcases/kernel/syzkaller-repros/.gitignore |   1 +
 testcases/kernel/syzkaller-repros/Makefile   | 105 +++++++++++++++
 testcases/kernel/syzkaller-repros/README.md  |  45 +++++++
 testcases/kernel/syzkaller-repros/syzwrap.c  | 134 +++++++++++++++++++
 testcases/linux-arts                         |   1 +
 10 files changed, 306 insertions(+)
 create mode 100644 runtest/.gitignore
 create mode 100644 testcases/kernel/syzkaller-repros/.gitignore
 create mode 100644 testcases/kernel/syzkaller-repros/Makefile
 create mode 100644 testcases/kernel/syzkaller-repros/README.md
 create mode 100644 testcases/kernel/syzkaller-repros/syzwrap.c
 create mode 160000 testcases/linux-arts
.gitmodules +4 -0
index 1c9e9c38a..2b9e836e6 100644
@@ -1,3 +1,7 @@
 [submodule "testcases/kernel/mce-test"]
 	path = testcases/kernel/mce-test
 	url = git://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/mce-test.git
+[submodule "testcases/linux-arts"]
+	path = testcases/linux-arts
+	url = https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-arts.git
+	shallow = true
configure.ac +12 -0
index 1d3ea58d0..20293040b 100644
@@ -271,6 +271,18 @@ else
     AC_SUBST([WITH_OPEN_POSIX_TESTSUITE],["no"])
 fi
 
+AC_ARG_WITH([syzkaller-repros],
+  [AC_HELP_STRING([--with-syzkaller-repros],
+    [compile and install Syzkaller reproducers (default=no)])],
+  [with_syzkaller_repros=$withval],
+  [with_syzkaller_repros=no]
+)
+if test "x$with_syzkaller_repros" = xyes; then
+    AC_SUBST([WITH_SYZKALLER_REPROS],["yes"])
+else
+    AC_SUBST([WITH_SYZKALLER_REPROS],["no"])
+fi
+
 # TODO: testcases/realtime requires bash and python.
 AC_ARG_WITH([realtime-testsuite],
   [AC_HELP_STRING([--with-realtime-testsuite],
include/mk/features.mk.in +2 -0
index 8e561b738..3ab7f4721 100644
@@ -47,3 +47,5 @@ WITH_REALTIME_TESTSUITE		:= no
 else
 WITH_REALTIME_TESTSUITE		:= @WITH_REALTIME_TESTSUITE@
 endif
+
+WITH_SYZKALLER_REPROS		:= @WITH_SYZKALLER_REPROS@
runtest/.gitignore new file +1 -0
new file mode 100644
index 000000000..2ae05bfac
@@ -0,0 +1 @@
+syzkaller*
testcases/kernel/Makefile +1 -0
index 3319b3163..0150cfb4f 100644
@@ -53,6 +53,7 @@ SUBDIRS			+= connectors \
 			   sched \
 			   security \
 			   sound \
+			   syzkaller-repros \
 			   tracing \
 			   uevents \
 
testcases/kernel/syzkaller-repros/.gitignore new file +1 -0
new file mode 100644
index 000000000..dbda1c71f
@@ -0,0 +1 @@
+syzwrap
testcases/kernel/syzkaller-repros/Makefile new file +105 -0

105 lines not on this page · raw message

testcases/kernel/syzkaller-repros/README.md new file +45 -0

45 lines not on this page · raw message

testcases/kernel/syzkaller-repros/syzwrap.c new file +134 -0

134 lines not on this page · raw message

testcases/linux-arts new file +1 -0
new file mode 160000
index 000000000..e39dd3846
@@ -0,0 +1 @@
+Subproject commit e39dd38466d956a7a9b6c061163cba783cf09b2e
Signature · 1 line
2.26.2
#1 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Hi Richard,

Quoted 4 lines

So this has now being floating in limbo for some time. My preference is to merge it to make it easy for users to try out with plenty of time before the next LTP release. It shouldn't break anything because it is hidden behind a configure switch.

+1

I plan to test it a bit and appreciate if somebody else also test it, but I see no problem to include this patchset.

Quoted 3 lines

V3:
+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

...

testcases/kernel/syzkaller-repros/Makefile line 13

Quoted 4 lines
testcases/kernel/syzkaller-repros/Makefile new file +4 -0
+ifeq ($(WITH_SYZKALLER_REPROS),yes)
+
+# This is mainly due to the -m32 flag, but there could be other problems.
+ifneq ($(HOST_CPU), x86_64))

nit: I guess, there should not be space, it should be ifneq ($(HOST_CPU),x86_64))

include/mk/config.mk
HOST_CPU := x86_64
=> I thought that the trailing space is omitted.
But working with it => not important.

Quoted 23 lines

+$(error "We currently only support building the Syzkaller reproducers on x86_64")

testcases/kernel/syzkaller-repros/Makefile new file +22 -0
+endif
+
+# The number of reproducers in each runtest file
+SYZKALLER_RUNFILES_SIZE ?= 100
+
+# Extra arguments to pass to syzwrap. Uncomment the below to add some
+# sandboxing.
+# SYZWRAP_ARGS ?= -s
+
+# Location where reproducers are installed
+SYZKALLER_INSTALL_DIR ?= $(abspath $(DESTDIR)/$(prefix)/testcases/bin)
+
+# If the reproducers directory is missing then we automatically clone the repo.
+# We then have to call make recursively to revaluate the targets
+SYZKALLER_REPROS_DIR ?= $(abs_top_srcdir)/testcases/linux-arts/syzkaller-repros/linux
+$(SYZKALLER_REPROS_DIR):
+	git submodule update --init $(abs_top_srcdir)/testcases/linux-arts
+	$(MAKE) syzkaller_runfiles
+
+SYZKALLER_REPROS_SRCS = $(wildcard $(SYZKALLER_REPROS_DIR)/*.c)
+
+# Some useful compiler flags for the LTP will cause problems with the

testcases/kernel/syzkaller-repros/Makefile line 45

Quoted 10 lines
testcases/kernel/syzkaller-repros/Makefile new file +9 -0
+# syzkaller repros so the repros have seperate flags
+SYZKALLER_CFLAGS ?= -pthread
+SYZKALLER_REPROS = $(subst $(abs_top_srcdir),$(abs_top_builddir),$(SYZKALLER_REPROS_SRCS:.c=))
 
+$(SYZKALLER_REPROS): %: %.c
+	-@if grep -q "__NR_mmap2" $^; then \
+		M32="-m32"; \
+	fi; \
+	$(CC) $(SYZKALLER_CFLAGS) $$M32 $(SYZKALLER_LDFLAGS) $^ -o $@; \
+	echo $(CC) $(SYZKALLER_CFLAGS) $$M32 $(SYZKALLER_LDFLAGS) $^ -o $@;

nit: it'd be worth to mention 32bit compilation environment. And I like this Makefile :)

I experimentally enabled it on all intel native builds in my LTP fork travis [1] and it runs well. Failed only in minimal variant [2] (no surprise). Fedora required to add glibc-devel.i686, other have support by default. It failed on ubuntu eon on timeout.
I'd suggest to chose one target where this would be running.
Whole job was prolonged from 2 hrs to 2,75 hrs, but running a single job wouldn't be that bad.

[1] https://travis-ci.org/github/pevik/ltp/builds/696513565
[2] https://travis-ci.org/github/pevik/ltp/jobs/696513571

Quoted 15 lines
testcases/kernel/syzkaller-repros/Makefile new file +15 -0
+
+# Generate the names of the runtest files. This uses Shell arithmetic to
+# calculate how many runtest files there will be.
+define SYZKALLER_RUNFILES !=
+	n=$(words $(SYZKALLER_REPROS));
+	m=$(SYZKALLER_RUNFILES_SIZE);
+	i=$$(( $$n / $$m + ($$n % $$m > 0) ));
+	while test $$i -gt 0;
+	do
+		echo $(top_srcdir)/runtest/syzkaller$$i;
+		i=$$(($$i - 1));
+	done
+endef
+
+++ b/testcases/kernel/syzkaller-repros/README.md

...

testcases/kernel/syzkaller-repros/README.md line 9

Quoted 3 lines
testcases/kernel/syzkaller-repros/README.md new file +3 -0
+## Instructions
+
+1. Run `ltp/configure` with `--with-syzkaller-repros`.

nit: I'd omit ltp/ (=> ./configure).

Quoted 2 lines

+2. Build and install the LTP as normal.
+3. Run one or more of syzkallerN runtest files where N is a number.

Kind regards,
Petr

#2 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Quoted 6 lines · Petr Vorel

Hi Richard,

Quoted 4 lines

So this has now being floating in limbo for some time. My preference is to merge it to make it easy for users to try out with plenty of time before the next LTP release. It shouldn't break anything because it is hidden behind a configure switch.

Quoted 10 lines

+1

I plan to test it a bit and appreciate if somebody else also test it, but I see no problem to include this patchset.

Quoted 3 lines
Quoted 1 line

V3:

+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

You can send patch to me against linux-arts for this and I will pull it in.

Dmitry, is that okay with you. This could make it easier for you and reduce your work.

thanks,
-- Shuah

#3 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Quoted 19 lines · Shuah Khan
Quoted 6 lines · Petr Vorel

Hi Richard,

Quoted 4 lines

So this has now being floating in limbo for some time. My preference is to merge it to make it easy for users to try out with plenty of time before the next LTP release. It shouldn't break anything because it is hidden behind a configure switch.

Quoted 10 lines

+1

I plan to test it a bit and appreciate if somebody else also test it, but I see no problem to include this patchset.

Quoted 3 lines
Quoted 1 line

V3:

+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

Quoted 5 lines

You can send patch to me against linux-arts for this and I will pull it in.

Dmitry, is that okay with you. This could make it easier for you and reduce your work.

Hi,

I don't have any particular comments.
I assume Richard tested it and it works. if so, it's fine with me :) I don't have any concrete plans to use this at the moment. We have a corpus of reproducers in syzkaller format and we can run these. This should be more useful for kernel continuous integration systems and distro testing.

#4 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Quoted 26 lines · Dmitry Vyukov
Quoted 19 lines · Shuah Khan
Quoted 6 lines · Petr Vorel

Hi Richard,

Quoted 4 lines

So this has now being floating in limbo for some time. My preference is to merge it to make it easy for users to try out with plenty of time before the next LTP release. It shouldn't break anything because it is hidden behind a configure switch.

Quoted 10 lines

+1

I plan to test it a bit and appreciate if somebody else also test it, but I see no problem to include this patchset.

Quoted 3 lines
Quoted 1 line

V3:

+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

Quoted 5 lines

You can send patch to me against linux-arts for this and I will pull it in.

Dmitry, is that okay with you. This could make it easier for you and reduce your work.

Quoted 9 lines

Hi,

I don't have any particular comments.
I assume Richard tested it and it works. if so, it's fine with me :) I don't have any concrete plans to use this at the moment. We have a corpus of reproducers in syzkaller format and we can run these. This should be more useful for kernel continuous integration systems and distro testing.

Right. That is what I was thinking that this is more relevant for kernel developers, CI and distros.

Richard, Please send the patch for linux-arts to me once Petr gives it a try and I will apply it.

thanks,
-- Shuah

thanks,
-- Shuah

#5 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Hi Shuah,

...

Quoted 7 lines
Quoted 6 lines

I don't have any particular comments.
I assume Richard tested it and it works. if so, it's fine with me :) I don't have any concrete plans to use this at the moment. We have a corpus of reproducers in syzkaller format and we can run these. This should be more useful for kernel continuous integration systems and distro testing.

Quoted 5 lines

Right. That is what I was thinking that this is more relevant for kernel developers, CI and distros.

Richard, Please send the patch for linux-arts to me once Petr gives it a try and I will apply it.

NOTE: this patch is for LTP. But maybe I miss something (some other patch for linux-arts I overlooked).

Kind regards,
Petr

#6 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Quoted 10 lines · Petr Vorel

Hi Shuah,

...

Quoted 6 lines
Quoted 6 lines

I don't have any particular comments.
I assume Richard tested it and it works. if so, it's fine with me :) I don't have any concrete plans to use this at the moment. We have a corpus of reproducers in syzkaller format and we can run these. This should be more useful for kernel continuous integration systems and distro testing.

Quoted 8 lines
Quoted 5 lines

Right. That is what I was thinking that this is more relevant for kernel developers, CI and distros.

Richard, Please send the patch for linux-arts to me once Petr gives it a try and I will apply it.

NOTE: this patch is for LTP. But maybe I miss something (some other patch for linux-arts I overlooked).

Possibly I misread the

V3:
+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

If this patch doesn't intend to update syzkaller-repo, there is nothing to do for linux-arts. I thought that this patch is for Dmitry's syzkaller repo I update from and looking get this into linux-arts directly.

Since this is LTP patch, ignore my comments. Sorry for the noise.

thanks,
-- Shuah

#7 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Hello,

Quoted 31 lines · Shuah Khan
Quoted 10 lines · Petr Vorel

Hi Shuah,

...

Quoted 6 lines
Quoted 6 lines

I don't have any particular comments.
I assume Richard tested it and it works. if so, it's fine with me :) I don't have any concrete plans to use this at the moment. We have a corpus of reproducers in syzkaller format and we can run these. This should be more useful for kernel continuous integration systems and distro testing.

Quoted 8 lines
Quoted 5 lines

Right. That is what I was thinking that this is more relevant for kernel developers, CI and distros.

Richard, Please send the patch for linux-arts to me once Petr gives it a try and I will apply it.

NOTE: this patch is for LTP. But maybe I miss something (some other patch for linux-arts I overlooked).

Possibly I misread the

V3:
+ Updated linux-arts commit (thanks Dmitry and Shuah for updating those!)
+ Fixed AC macro

If this patch doesn't intend to update syzkaller-repo, there is nothing to do for linux-arts. I thought that this patch is for Dmitry's syzkaller repo I update from and looking get this into linux-arts directly.

Quoted 4 lines

Since this is LTP patch, ignore my comments. Sorry for the noise.

thanks,
-- Shuah

No problem at all, I should have made that more clear.

Infact I will send a seperate patch to linux-arts mentioning the LTP wrapper.

Signature · 2 lines
Thank you,
Richard.
#8 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Hi Shuah, Richard,

Quoted 7 lines
Quoted 6 lines

If this patch doesn't intend to update syzkaller-repo, there is nothing to do for linux-arts. I thought that this patch is for Dmitry's syzkaller repo I update from and looking get this into linux-arts directly.

Since this is LTP patch, ignore my comments. Sorry for the noise.

Quoted 7 lines
Quoted 2 lines

thanks,
-- Shuah

No problem at all, I should have made that more clear.

Infact I will send a seperate patch to linux-arts mentioning the LTP wrapper.

Thanks you both for clarifying.

@Jan, @Cyril, @Yang, @Li: any ack/objection to this patch?

Kind regards,
Petr

#9 lore raw

PATCH v3 1/1 Wrapper for Syzkaller reproducers

Quoted 12 lines · Petr Vorel

Hi Shuah, Richard,

Quoted 9 lines
Quoted 9 lines

If this patch doesn't intend to update syzkaller-repo, there is nothing to do for linux-arts. I thought that this patch is for Dmitry's syzkaller repo I update from and looking get this into linux-arts directly.

Since this is LTP patch, ignore my comments. Sorry for the noise.

thanks,
-- Shuah

Quoted 8 lines
Quoted 4 lines

No problem at all, I should have made that more clear.

Infact I will send a seperate patch to linux-arts mentioning the LTP wrapper.

Thanks you both for clarifying.

@Jan, @Cyril, @Yang, @Li: any ack/objection to this patch?

I have no objection to merging the syzkaller patch.
Build and run some of the testcase locally(Fedora32) by manual, it works well.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200615/49a22ccd/attachment.htm>