aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-09-13 19:30:55 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-09-14 09:55:45 +0200
commitfab7609913c9787bdb79602ff716f5e0d1598c98 (patch)
tree7bd1cebde179e383cbbf5868e5b664c7d0f7e88f
parent3f1d02b23f99beaf2bf3b06c11642e56578b12ee (diff)
tools/check-whitespace.sh: check for trailing whitespaces
File types that we don't format automatically can end up with such basic untidiness as trailing whitespaces. Check for these. Remove all existing precedents.
-rw-r--r--Makefile7
-rwxr-xr-xdashboard/config/util.sh2
-rw-r--r--docs/linux/external_fuzzing_usb.md82
-rw-r--r--docs/linux/setup_linux-host_android-device_arm-kernel.md2
-rw-r--r--docs/linux/setup_linux-host_qemu-vm_arm-kernel.md4
-rw-r--r--docs/linux/setup_linux-host_qemu-vm_arm64-kernel.md2
-rw-r--r--docs/linux/setup_linux-host_qemu-vm_s390x-kernel.md2
-rw-r--r--docs/linux/setup_ubuntu-host_odroid-c2-board_arm64-kernel.md14
-rw-r--r--docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md2
-rw-r--r--docs/pseudo_syscalls.md2
-rw-r--r--docs/syscall_descriptions.md2
-rw-r--r--docs/syscall_descriptions_syntax.md2
-rw-r--r--docs/syzbot.md6
-rw-r--r--docs/trusty/README.md2
-rwxr-xr-xtools/check-whitespace.sh31
-rwxr-xr-xtools/create_f2fs_image.sh3
16 files changed, 99 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index ede67966a..542a3ac93 100644
--- a/Makefile
+++ b/Makefile
@@ -102,7 +102,7 @@ endif
bin/syz-extract bin/syz-fmt \
extract generate generate_go generate_sys \
format format_go format_cpp format_sys \
- tidy test test_race check_copyright check_language check_links check_diff check_commits \
+ tidy test test_race check_copyright check_language check_whitespace check_links check_diff check_commits \
presubmit presubmit_smoke presubmit_build presubmit_arch presubmit_big presubmit_race presubmit_old
all: host target
@@ -266,7 +266,7 @@ presubmit:
presubmit_smoke:
$(MAKE) generate
- $(MAKE) -j100 check_commits check_diff check_copyright check_language check_links presubmit_build tidy
+ $(MAKE) -j100 check_commits check_diff check_copyright check_language check_whitespace check_links presubmit_build tidy
$(MAKE) test
presubmit_build:
@@ -353,6 +353,9 @@ check_copyright:
check_language:
./tools/check-language.sh
+check_whitespace:
+ ./tools/check-whitespace.sh
+
check_commits:
./tools/check-commits.sh
diff --git a/dashboard/config/util.sh b/dashboard/config/util.sh
index 5b0aa9a06..656719740 100755
--- a/dashboard/config/util.sh
+++ b/dashboard/config/util.sh
@@ -66,7 +66,7 @@ function util_add_usb_bits {
scripts/config -d CONFIG_USB_GADGETFS
scripts/config -d CONFIG_USB_LIBCOMPOSITE
scripts/config -d CONFIG_USB_CONFIGFS
-
+
scripts/config -e CONFIG_USB_GADGET
scripts/config -e CONFIG_USB_DUMMY_HCD
scripts/config -e CONFIG_USB_RAW_GADGET
diff --git a/docs/linux/external_fuzzing_usb.md b/docs/linux/external_fuzzing_usb.md
index 226576ec1..1309bf5ba 100644
--- a/docs/linux/external_fuzzing_usb.md
+++ b/docs/linux/external_fuzzing_usb.md
@@ -151,48 +151,48 @@ These instructions describe how to set this up on a Raspberry Pi Zero W, but any
9. Download syzkaller, apply the patch below and build `syz-executor`:
- ``` c
- diff --git a/executor/common_usb.h b/executor/common_usb.h
- index e342d808..278c2f4e 100644
- --- a/executor/common_usb.h
- +++ b/executor/common_usb.h
- @@ -269,9 +269,7 @@ static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatil
-
- // TODO: consider creating two dummy_udc's per proc to increace the chance of
- // triggering interaction between multiple USB devices within the same program.
- - char device[32];
- - sprintf(&device[0], "dummy_udc.%llu", procid);
- - rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
- + rv = usb_raw_init(fd, speed, "20980000.usb", "20980000.usb");
- if (rv < 0) {
- debug("syz_usb_connect: usb_raw_init failed with %d\n", rv);
- return rv;
- diff --git a/executor/executor.cc b/executor/executor.cc
- index 34949a01..1afcb288 100644
- --- a/executor/executor.cc
- +++ b/executor/executor.cc
- @@ -604,8 +604,8 @@ retry:
- call_extra_cover = true;
- }
- if (strncmp(syscalls[call_num].name, "syz_usb_connect", strlen("syz_usb_connect")) == 0) {
- - prog_extra_timeout = 2000;
- - call_extra_timeout = 2000;
- + prog_extra_timeout = 5000;
- + call_extra_timeout = 5000;
- }
- if (strncmp(syscalls[call_num].name, "syz_usb_control_io", strlen("syz_usb_control_io")) == 0)
- call_extra_timeout = 300;
- ```
+``` c
+diff --git a/executor/common_usb.h b/executor/common_usb.h
+index e342d808..278c2f4e 100644
+--- a/executor/common_usb.h
++++ b/executor/common_usb.h
+@@ -269,9 +269,7 @@ static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatil
+
+ // TODO: consider creating two dummy_udc's per proc to increace the chance of
+ // triggering interaction between multiple USB devices within the same program.
+- char device[32];
+- sprintf(&device[0], "dummy_udc.%llu", procid);
+- rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
++ rv = usb_raw_init(fd, speed, "20980000.usb", "20980000.usb");
+ if (rv < 0) {
+ debug("syz_usb_connect: usb_raw_init failed with %d\n", rv);
+ return rv;
+diff --git a/executor/executor.cc b/executor/executor.cc
+index 34949a01..1afcb288 100644
+--- a/executor/executor.cc
++++ b/executor/executor.cc
+@@ -604,8 +604,8 @@ retry:
+ call_extra_cover = true;
+ }
+ if (strncmp(syscalls[call_num].name, "syz_usb_connect", strlen("syz_usb_connect")) == 0) {
+- prog_extra_timeout = 2000;
+- call_extra_timeout = 2000;
++ prog_extra_timeout = 5000;
++ call_extra_timeout = 5000;
+ }
+ if (strncmp(syscalls[call_num].name, "syz_usb_control_io", strlen("syz_usb_control_io")) == 0)
+ call_extra_timeout = 300;
+```
- ``` bash
- go get -u -d github.com/google/syzkaller/prog
- cd ~/gopath/src/github.com/google/syzkaller
- # Put the patch above into ./syzkaller.patch
- git apply ./syzkaller.patch
- make executor
- mkdir ~/syz-bin
- cp bin/linux_arm/syz-executor ~/syz-bin/
- ```
+``` bash
+go get -u -d github.com/google/syzkaller/prog
+cd ~/gopath/src/github.com/google/syzkaller
+# Put the patch above into ./syzkaller.patch
+git apply ./syzkaller.patch
+make executor
+mkdir ~/syz-bin
+cp bin/linux_arm/syz-executor ~/syz-bin/
+```
10. Build `syz-execprog` on your host machine for arm32 with `make TARGETARCH=arm execprog` and copy to `~/syz-bin` onto the SD card. You may try building syz-execprog on the Raspberry Pi itself, but that worked poorly for me due to large memory consumption during the compilation process.
diff --git a/docs/linux/setup_linux-host_android-device_arm-kernel.md b/docs/linux/setup_linux-host_android-device_arm-kernel.md
index a4859fdf5..90996637a 100644
--- a/docs/linux/setup_linux-host_android-device_arm-kernel.md
+++ b/docs/linux/setup_linux-host_android-device_arm-kernel.md
@@ -5,7 +5,7 @@
This document details the steps involved in setting up a syzkaller instance fuzzing an `arm32/64` linux kernel on an Android device.
Some features of syzkaller may not yet work properly on `arm32`. For example, not all debugging and test coverage features are available in the Linux kernel for `arm32`, limiting the efficacy of syskaller in finding bugs fast.
-
+
These were tested on an NXP Pico-Pi-IMX7D following the instructions [here](https://developer.android.com/things/hardware/developer-kits.html).
You may find additional details in syzkaller's `adb` vm implementation [here](/vm/adb/adb.go).
diff --git a/docs/linux/setup_linux-host_qemu-vm_arm-kernel.md b/docs/linux/setup_linux-host_qemu-vm_arm-kernel.md
index c88d9a8f6..3745cbcc1 100644
--- a/docs/linux/setup_linux-host_qemu-vm_arm-kernel.md
+++ b/docs/linux/setup_linux-host_qemu-vm_arm-kernel.md
@@ -5,7 +5,7 @@
Obtain a fresh `arm-linux-gnueabihf-gcc`. Latest Debian distributions provide
version 7.2.0, which should be enough. Otherwise you can download Linaro
compiler [here](https://www.linaro.org/downloads).
-
+
# Kernel
The instructions are tested with `v4.16.1`. Check that you have/backport
@@ -77,7 +77,7 @@ debugfs /sys/kernel/debug debugfs defaults 0 0
```
Then replace `output/target/etc/ssh/sshd_config` with the following contents:
-
+
```
PermitRootLogin yes
PasswordAuthentication yes
diff --git a/docs/linux/setup_linux-host_qemu-vm_arm64-kernel.md b/docs/linux/setup_linux-host_qemu-vm_arm64-kernel.md
index d4eab5b43..a5148916d 100644
--- a/docs/linux/setup_linux-host_qemu-vm_arm64-kernel.md
+++ b/docs/linux/setup_linux-host_qemu-vm_arm64-kernel.md
@@ -109,7 +109,7 @@ At the top of /etc/init.d/S50sshd add the following lines:
mount -t debugfs none /sys/kernel/debug
chmod 777 /sys/kernel/debug/kcov
-Comment out the line
+Comment out the line
/usr/bin/ssh-keygen -A
diff --git a/docs/linux/setup_linux-host_qemu-vm_s390x-kernel.md b/docs/linux/setup_linux-host_qemu-vm_s390x-kernel.md
index 162016c62..adcb63c75 100644
--- a/docs/linux/setup_linux-host_qemu-vm_s390x-kernel.md
+++ b/docs/linux/setup_linux-host_qemu-vm_s390x-kernel.md
@@ -75,7 +75,7 @@ Now you should have `vmlinux` (kernel binary) and `bzImage` (packed kernel image
``` bash
$ ls $KERNEL/vmlinux
$KERNEL/vmlinux
-$ ls $KERNEL/arch/s390/boot/bzImage
+$ ls $KERNEL/arch/s390/boot/bzImage
$KERNEL/arch/s390/boot/bzImage
```
diff --git a/docs/linux/setup_ubuntu-host_odroid-c2-board_arm64-kernel.md b/docs/linux/setup_ubuntu-host_odroid-c2-board_arm64-kernel.md
index dfcd2eaa4..6ecf5a894 100644
--- a/docs/linux/setup_ubuntu-host_odroid-c2-board_arm64-kernel.md
+++ b/docs/linux/setup_ubuntu-host_odroid-c2-board_arm64-kernel.md
@@ -80,7 +80,7 @@ Some message
``` bash
$ ssh root@172.16.0.31
- root@172.16.0.31's password:
+ root@172.16.0.31's password:
...
Last login: Thu Feb 11 11:30:51 2016
root@odroid64:~#
@@ -93,7 +93,7 @@ This hub has support for a feature called [Per Port Power Switching](http://www.
[To be able to open the hub device entry](http://www.janosgyerik.com/adding-udev-rules-for-usb-debugging-android-devices/) under `/dev/` without being root, add the following file to `/etc/udev/rules.d/` on the host machine:
``` bash
-$ cat /etc/udev/rules.d/10-local.rules
+$ cat /etc/udev/rules.d/10-local.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="2001", ATTR{idProduct}=="f103", MODE="0664", GROUP="plugdev"
```
@@ -101,7 +101,7 @@ SUBSYSTEM=="usb", ATTR{idVendor}=="2001", ATTR{idProduct}=="f103", MODE="0664",
Don't forget to replug the hub after you add this file.
``` bash
-$ lsusb
+$ lsusb
...
Bus 003 Device 026: ID 2001:f103 D-Link Corp. DUB-H7 7-port USB 2.0 hub
...
@@ -159,14 +159,14 @@ index 165cf9783a5d..ff8b40dca9e2 100644
@@ -653,6 +653,11 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
# Tell gcc to never replace conditional load with a non-conditional one
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
-
+
+# Stop gcc from converting switches into a form that defeats dead code
+# elimination and can subsequently lead to calls to intentionally
+# undefined functions appearing in the final link.
+KBUILD_CFLAGS += $(call cc-option,--param=max-fsm-thread-path-insns=1)
+
include scripts/Makefile.gcc-plugins
-
+
ifdef CONFIG_READABLE_ASM
```
@@ -177,12 +177,12 @@ index 9576775a86f6..8bc4eb36fc1b 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -11,7 +11,6 @@ CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
-
+
CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
-fasan-shadow-offset=$(KASAN_SHADOW_OFFSET) \
- --param asan-stack=1 --param asan-globals=1 \
--param asan-instrumentation-with-call-threshold=$(call_threshold))
-
+
ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
```
diff --git a/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md b/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md
index 0efc42196..faa087c60 100644
--- a/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md
+++ b/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md
@@ -70,7 +70,7 @@ Now you should have `vmlinux` (kernel binary) and `bzImage` (packed kernel image
``` bash
$ ls $KERNEL/vmlinux
$KERNEL/vmlinux
-$ ls $KERNEL/arch/x86/boot/bzImage
+$ ls $KERNEL/arch/x86/boot/bzImage
$KERNEL/arch/x86/boot/bzImage
```
diff --git a/docs/pseudo_syscalls.md b/docs/pseudo_syscalls.md
index 82c2bfeb8..5247dd6b3 100644
--- a/docs/pseudo_syscalls.md
+++ b/docs/pseudo_syscalls.md
@@ -4,7 +4,7 @@ Besides regular system calls, a [syscall
description](syscall_descriptions.md) file can also contain
pseudo-syscalls. These are C functions defined in the
executor. When a test program uses a pseudo-syscall, the executor
-will generate the pseudo-syscall function code in the resulting C program.
+will generate the pseudo-syscall function code in the resulting C program.
This allows a test program to have specific code blocks to perform
certain actions, they may also be used as more test-friendly wrappers
diff --git a/docs/syscall_descriptions.md b/docs/syscall_descriptions.md
index a69932e27..fbb9f67fa 100644
--- a/docs/syscall_descriptions.md
+++ b/docs/syscall_descriptions.md
@@ -170,7 +170,7 @@ close(r0)
Syscall arguments are always `in`, return values are `out` and pointer indirections
have explicit direction as `ptr` type attribute. Also, it is possible to specify
-direction attribute individually for struct fields to account for more complex
+direction attribute individually for struct fields to account for more complex
producer/consumer scenarious with structs that include both input/output resources.
<div id="values"/>
diff --git a/docs/syscall_descriptions_syntax.md b/docs/syscall_descriptions_syntax.md
index 5af302de8..76cdc90b1 100644
--- a/docs/syscall_descriptions_syntax.md
+++ b/docs/syscall_descriptions_syntax.md
@@ -365,7 +365,7 @@ define MY_PATH_MAX PATH_MAX + 2
## Misc
Description files also contain `include` directives that refer to Linux kernel header files,
-`incdir` directives that refer to custom Linux kernel header directories
+`incdir` directives that refer to custom Linux kernel header directories
and `define` directives that define symbolic constant values.
The syzkaller executor defines some [pseudo system calls](./pseudo_syscalls.md)
diff --git a/docs/syzbot.md b/docs/syzbot.md
index fbeb0e070..bffd6994b 100644
--- a/docs/syzbot.md
+++ b/docs/syzbot.md
@@ -176,7 +176,7 @@ Suggestions and patches that improve bisection quality for common cases are
`syzbot` supports cause bisection (find the commit that introduces a bug) and
fix bisection (find the commit that fixes a bug).
-The web UI for a specific kernel
+The web UI for a specific kernel
(say [upstream linux](https://syzkaller.appspot.com/upstream)) shows the
`Bisected` status for all bugs.
@@ -227,7 +227,7 @@ the provided crash report on the provided reproducer on a freshly-booted
machine, so the reproducer worked for it somehow.
Note: if the report contains `userspace arch: i386`,
-then the program needs to be built with `-m32` flag.
+then the program needs to be built with `-m32` flag.
`syzbot` uses GCE VMs for testing, but *usually* it is not important.
@@ -405,7 +405,7 @@ ask tree maintainers for priority handling.
However, syzbot kernel config always includes `CONFIG_DEBUG_AID_FOR_SYZBOT=y` setting,
which is not normally present in kernel. What was used for particularly elusive bugs in the past
is temporary merging some additional debugging code into `linux-next` under this config setting
-(e.g. more debug checks and/or debug output) and waiting for new crash reports from syzbot.
+(e.g. more debug checks and/or debug output) and waiting for new crash reports from syzbot.
## Kernel configs
diff --git a/docs/trusty/README.md b/docs/trusty/README.md
index cad54ae76..5013dc5db 100644
--- a/docs/trusty/README.md
+++ b/docs/trusty/README.md
@@ -151,7 +151,7 @@ using config along the lines of (substitute actual values for `$KERNEL`, `$SYZKA
"ppoll",
"dup3",
"tkill",
- "gettid",
+ "gettid",
"close"
]
}
diff --git a/tools/check-whitespace.sh b/tools/check-whitespace.sh
new file mode 100755
index 000000000..a23196601
--- /dev/null
+++ b/tools/check-whitespace.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# Copyright 2020 syzkaller project authors. All rights reserved.
+# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+FILES=0
+FAILED=""
+RE="[[:space:]]$"
+LAST_EMPTY=""
+for F in $(find . -name "*.sh" -o -name "*.S" -o -name "*.py" -o -name "*.yml" -o -name "*.yaml" -o -name "*.md" | \
+ egrep -v "/vendor/|/gen/"); do
+ ((FILES+=1))
+ L=0
+ while IFS= read -r LINE; do
+ ((L+=1))
+ if [[ $LINE =~ $RE ]]; then
+ echo "$F:$L:1: Trailing whitespace at the end of the line. Please remove."
+ echo "$LINE"
+ FAILED="1"
+ fi
+ LAST_EMPTY=""
+ if [ "$LINE" == "" ]; then
+ LAST_EMPTY="1"
+ fi
+ done < "$F"
+ if [ "$LAST_EMPTY" != "" ]; then
+ echo "$F:$L:1: Trailing empty line at the end of the file. Please remove."
+ FAILED="1"
+ fi
+done
+if [ "$FAILED" != "" ]; then exit 1; fi
+echo "$FILES files checked for whitespaces"
diff --git a/tools/create_f2fs_image.sh b/tools/create_f2fs_image.sh
index 5880f1352..03d34c76d 100755
--- a/tools/create_f2fs_image.sh
+++ b/tools/create_f2fs_image.sh
@@ -22,7 +22,7 @@ for op1 in "${Op1[@]}"; do
for op4 in "${Op4[@]}"; do
echo mkfs.f2fs ${op1}${op2}${op3}${op4} disk.raw
fallocate -l 64M disk.raw
- mkfs.f2fs "${op1}${op2}${op3}${op4}" disk.raw
+ mkfs.f2fs "${op1}${op2}${op3}${op4}" disk.raw
out="$dir/../sys/linux/test/syz_mount_image_f2fs_$dex"
echo "# Code generated by tools/create_f2fs_image.sh. DO NOT EDIT." > $out
echo "# requires: manual" >> $out
@@ -34,4 +34,3 @@ for op1 in "${Op1[@]}"; do
done
done
done
-