Commit 704a0afb authored by David S. Miller's avatar David S. Miller

Merge branch 'WireGuard-bug-fixes-and-cleanups'

Jason A. Donenfeld says:

====================
WireGuard bug fixes and cleanups

I've been working through some personal notes and also the whole git
repo history of the out-of-tree module, looking for places where
tradeoffs were made (and subsequently forgotten about) for old kernels.
The first two patches in this series clean up those. The first one does
so in the self-tests and self-test harness, where we're now able to
expand test coverage by a bit, and we're now cooking away tests on every
commit to both the wireguard-linux repo and to net-next. The second one
removes a workaround for a skbuff.h bug that was fixed long ago.
Finally, the last patch in the series fixes in a bug unearthed by newer
Qualcomm chipsets running the rmnet_perf driver, which does UDP GRO.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3b477d6c 736775d0
...@@ -83,13 +83,10 @@ static inline __be16 wg_skb_examine_untrusted_ip_hdr(struct sk_buff *skb) ...@@ -83,13 +83,10 @@ static inline __be16 wg_skb_examine_untrusted_ip_hdr(struct sk_buff *skb)
static inline void wg_reset_packet(struct sk_buff *skb) static inline void wg_reset_packet(struct sk_buff *skb)
{ {
const int pfmemalloc = skb->pfmemalloc;
skb_scrub_packet(skb, true); skb_scrub_packet(skb, true);
memset(&skb->headers_start, 0, memset(&skb->headers_start, 0,
offsetof(struct sk_buff, headers_end) - offsetof(struct sk_buff, headers_end) -
offsetof(struct sk_buff, headers_start)); offsetof(struct sk_buff, headers_start));
skb->pfmemalloc = pfmemalloc;
skb->queue_mapping = 0; skb->queue_mapping = 0;
skb->nohdr = 0; skb->nohdr = 0;
skb->peeked = 0; skb->peeked = 0;
......
...@@ -333,6 +333,7 @@ static int wg_receive(struct sock *sk, struct sk_buff *skb) ...@@ -333,6 +333,7 @@ static int wg_receive(struct sock *sk, struct sk_buff *skb)
wg = sk->sk_user_data; wg = sk->sk_user_data;
if (unlikely(!wg)) if (unlikely(!wg))
goto err; goto err;
skb_mark_not_on_list(skb);
wg_packet_receive(wg, skb); wg_packet_receive(wg, skb);
return 0; return 0;
......
...@@ -37,7 +37,7 @@ n2() { pretty 2 "$*"; maybe_exec ip netns exec $netns2 "$@"; } ...@@ -37,7 +37,7 @@ n2() { pretty 2 "$*"; maybe_exec ip netns exec $netns2 "$@"; }
ip0() { pretty 0 "ip $*"; ip -n $netns0 "$@"; } ip0() { pretty 0 "ip $*"; ip -n $netns0 "$@"; }
ip1() { pretty 1 "ip $*"; ip -n $netns1 "$@"; } ip1() { pretty 1 "ip $*"; ip -n $netns1 "$@"; }
ip2() { pretty 2 "ip $*"; ip -n $netns2 "$@"; } ip2() { pretty 2 "ip $*"; ip -n $netns2 "$@"; }
sleep() { read -t "$1" -N 0 || true; } sleep() { read -t "$1" -N 1 || true; }
waitiperf() { pretty "${1//*-}" "wait for iperf:5201"; while [[ $(ss -N "$1" -tlp 'sport = 5201') != *iperf3* ]]; do sleep 0.1; done; } waitiperf() { pretty "${1//*-}" "wait for iperf:5201"; while [[ $(ss -N "$1" -tlp 'sport = 5201') != *iperf3* ]]; do sleep 0.1; done; }
waitncatudp() { pretty "${1//*-}" "wait for udp:1111"; while [[ $(ss -N "$1" -ulp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; } waitncatudp() { pretty "${1//*-}" "wait for udp:1111"; while [[ $(ss -N "$1" -ulp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
waitncattcp() { pretty "${1//*-}" "wait for tcp:1111"; while [[ $(ss -N "$1" -tlp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; } waitncattcp() { pretty "${1//*-}" "wait for tcp:1111"; while [[ $(ss -N "$1" -tlp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
...@@ -294,12 +294,9 @@ ip1 -6 rule add table main suppress_prefixlength 0 ...@@ -294,12 +294,9 @@ ip1 -6 rule add table main suppress_prefixlength 0
ip1 -4 route add default dev wg0 table 51820 ip1 -4 route add default dev wg0 table 51820
ip1 -4 rule add not fwmark 51820 table 51820 ip1 -4 rule add not fwmark 51820 table 51820
ip1 -4 rule add table main suppress_prefixlength 0 ip1 -4 rule add table main suppress_prefixlength 0
# suppress_prefixlength only got added in 3.12, and we want to support 3.10+. # Flood the pings instead of sending just one, to trigger routing table reference counting bugs.
if [[ $(ip1 -4 rule show all) == *suppress_prefixlength* ]]; then n1 ping -W 1 -c 100 -f 192.168.99.7
# Flood the pings instead of sending just one, to trigger routing table reference counting bugs. n1 ping -W 1 -c 100 -f abab::1111
n1 ping -W 1 -c 100 -f 192.168.99.7
n1 ping -W 1 -c 100 -f abab::1111
fi
n0 iptables -t nat -F n0 iptables -t nat -F
ip0 link del vethrc ip0 link del vethrc
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
PWD := $(shell pwd) PWD := $(shell pwd)
CHOST := $(shell gcc -dumpmachine) CHOST := $(shell gcc -dumpmachine)
HOST_ARCH := $(firstword $(subst -, ,$(CHOST)))
ifneq (,$(ARCH)) ifneq (,$(ARCH))
CBUILD := $(subst -gcc,,$(lastword $(subst /, ,$(firstword $(wildcard $(foreach bindir,$(subst :, ,$(PATH)),$(bindir)/$(ARCH)-*-gcc)))))) CBUILD := $(subst -gcc,,$(lastword $(subst /, ,$(firstword $(wildcard $(foreach bindir,$(subst :, ,$(PATH)),$(bindir)/$(ARCH)-*-gcc))))))
ifeq (,$(CBUILD)) ifeq (,$(CBUILD))
...@@ -37,19 +38,19 @@ endef ...@@ -37,19 +38,19 @@ endef
define file_download = define file_download =
$(DISTFILES_PATH)/$(1): $(DISTFILES_PATH)/$(1):
mkdir -p $(DISTFILES_PATH) mkdir -p $(DISTFILES_PATH)
flock -x $$@.lock -c '[ -f $$@ ] && exit 0; wget -O $$@.tmp $(MIRROR)$(1) || wget -t inf --retry-on-http-error=404 -O $$@.tmp $(2)$(1) || rm -f $$@.tmp' flock -x $$@.lock -c '[ -f $$@ ] && exit 0; wget -O $$@.tmp $(MIRROR)$(1) || wget -O $$@.tmp $(2)$(1) || rm -f $$@.tmp'
if echo "$(3) $$@.tmp" | sha256sum -c -; then mv $$@.tmp $$@; else rm -f $$@.tmp; exit 71; fi if echo "$(3) $$@.tmp" | sha256sum -c -; then mv $$@.tmp $$@; else rm -f $$@.tmp; exit 71; fi
endef endef
$(eval $(call tar_download,MUSL,musl,1.1.20,.tar.gz,https://www.musl-libc.org/releases/,44be8771d0e6c6b5f82dd15662eb2957c9a3173a19a8b49966ac0542bbd40d61)) $(eval $(call tar_download,MUSL,musl,1.1.24,.tar.gz,https://www.musl-libc.org/releases/,1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3))
$(eval $(call tar_download,LIBMNL,libmnl,1.0.4,.tar.bz2,https://www.netfilter.org/projects/libmnl/files/,171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81)) $(eval $(call tar_download,LIBMNL,libmnl,1.0.4,.tar.bz2,https://www.netfilter.org/projects/libmnl/files/,171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81))
$(eval $(call tar_download,IPERF,iperf,3.1.7,.tar.gz,http://downloads.es.net/pub/iperf/,a4ef73406fe92250602b8da2ae89ec53211f805df97a1d1d629db5a14043734f)) $(eval $(call tar_download,IPERF,iperf,3.7,.tar.gz,https://downloads.es.net/pub/iperf/,d846040224317caf2f75c843d309a950a7db23f9b44b94688ccbe557d6d1710c))
$(eval $(call tar_download,BASH,bash,5.0,.tar.gz,https://ftp.gnu.org/gnu/bash/,b4a80f2ac66170b2913efbfb9f2594f1f76c7b1afd11f799e22035d63077fb4d)) $(eval $(call tar_download,BASH,bash,5.0,.tar.gz,https://ftp.gnu.org/gnu/bash/,b4a80f2ac66170b2913efbfb9f2594f1f76c7b1afd11f799e22035d63077fb4d))
$(eval $(call tar_download,IPROUTE2,iproute2,5.1.0,.tar.gz,https://www.kernel.org/pub/linux/utils/net/iproute2/,9b43707d6075ecdca14803ca8ce0c8553848c49fa1586d12fd508d66577243f2)) $(eval $(call tar_download,IPROUTE2,iproute2,5.4.0,.tar.xz,https://www.kernel.org/pub/linux/utils/net/iproute2/,fe97aa60a0d4c5ac830be18937e18dc3400ca713a33a89ad896ff1e3d46086ae))
$(eval $(call tar_download,IPTABLES,iptables,1.6.1,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,0fc2d7bd5d7be11311726466789d4c65fb4c8e096c9182b56ce97440864f0cf5)) $(eval $(call tar_download,IPTABLES,iptables,1.8.4,.tar.bz2,https://www.netfilter.org/projects/iptables/files/,993a3a5490a544c2cbf2ef15cf7e7ed21af1845baf228318d5c36ef8827e157c))
$(eval $(call tar_download,NMAP,nmap,7.60,.tar.bz2,https://nmap.org/dist/,a8796ecc4fa6c38aad6139d9515dc8113023a82e9d787e5a5fb5fa1b05516f21)) $(eval $(call tar_download,NMAP,nmap,7.80,.tar.bz2,https://nmap.org/dist/,fcfa5a0e42099e12e4bf7a68ebe6fde05553383a682e816a7ec9256ab4773faa))
$(eval $(call tar_download,IPUTILS,iputils,s20161105,.tar.gz,https://github.com/iputils/iputils/archive/s20161105.tar.gz/#,f813092f03d17294fd23544b129b95cdb87fe19f7970a51908a6b88509acad8a)) $(eval $(call tar_download,IPUTILS,iputils,s20190709,.tar.gz,https://github.com/iputils/iputils/archive/s20190709.tar.gz/#,a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a))
$(eval $(call tar_download,WIREGUARD_TOOLS,WireGuard,0.0.20191212,.tar.xz,https://git.zx2c4.com/WireGuard/snapshot/,b0d718380f7a8822b2f12d75e462fa4eafa3a77871002981f367cd4fe2a1b071)) $(eval $(call tar_download,WIREGUARD_TOOLS,wireguard-tools,1.0.20191226,.tar.xz,https://git.zx2c4.com/wireguard-tools/snapshot/,aa8af0fdc9872d369d8c890a84dbc2a2466b55795dccd5b47721b2d97644b04f))
KERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug) KERNEL_BUILD_PATH := $(BUILD_PATH)/kernel$(if $(findstring yes,$(DEBUG_KERNEL)),-debug)
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
...@@ -59,23 +60,21 @@ export CFLAGS ?= -O3 -pipe ...@@ -59,23 +60,21 @@ export CFLAGS ?= -O3 -pipe
export LDFLAGS ?= export LDFLAGS ?=
export CPPFLAGS := -I$(BUILD_PATH)/include export CPPFLAGS := -I$(BUILD_PATH)/include
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
CROSS_COMPILE_FLAG := --host=$(CHOST) CROSS_COMPILE_FLAG := --host=$(CHOST)
NOPIE_GCC := gcc -fno-PIE
CFLAGS += -march=native CFLAGS += -march=native
STRIP := strip STRIP := strip
else else
$(info Cross compilation: building for $(CBUILD) using $(CHOST)) $(info Cross compilation: building for $(CBUILD) using $(CHOST))
CROSS_COMPILE_FLAG := --build=$(CBUILD) --host=$(CHOST) CROSS_COMPILE_FLAG := --build=$(CBUILD) --host=$(CHOST)
export CROSS_COMPILE=$(CBUILD)- export CROSS_COMPILE=$(CBUILD)-
NOPIE_GCC := $(CBUILD)-gcc -fno-PIE
STRIP := $(CBUILD)-strip STRIP := $(CBUILD)-strip
endif endif
ifeq ($(ARCH),aarch64) ifeq ($(ARCH),aarch64)
QEMU_ARCH := aarch64 QEMU_ARCH := aarch64
KERNEL_ARCH := arm64 KERNEL_ARCH := arm64
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
else else
QEMU_MACHINE := -cpu cortex-a53 -machine virt QEMU_MACHINE := -cpu cortex-a53 -machine virt
...@@ -85,7 +84,7 @@ else ifeq ($(ARCH),aarch64_be) ...@@ -85,7 +84,7 @@ else ifeq ($(ARCH),aarch64_be)
QEMU_ARCH := aarch64 QEMU_ARCH := aarch64
KERNEL_ARCH := arm64 KERNEL_ARCH := arm64
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm64/boot/Image
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
else else
QEMU_MACHINE := -cpu cortex-a53 -machine virt QEMU_MACHINE := -cpu cortex-a53 -machine virt
...@@ -95,7 +94,7 @@ else ifeq ($(ARCH),arm) ...@@ -95,7 +94,7 @@ else ifeq ($(ARCH),arm)
QEMU_ARCH := arm QEMU_ARCH := arm
KERNEL_ARCH := arm KERNEL_ARCH := arm
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
else else
QEMU_MACHINE := -cpu cortex-a15 -machine virt QEMU_MACHINE := -cpu cortex-a15 -machine virt
...@@ -105,7 +104,7 @@ else ifeq ($(ARCH),armeb) ...@@ -105,7 +104,7 @@ else ifeq ($(ARCH),armeb)
QEMU_ARCH := arm QEMU_ARCH := arm
KERNEL_ARCH := arm KERNEL_ARCH := arm
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/arm/boot/zImage
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm QEMU_MACHINE := -cpu host -machine virt,gic_version=host,accel=kvm
else else
QEMU_MACHINE := -cpu cortex-a15 -machine virt QEMU_MACHINE := -cpu cortex-a15 -machine virt
...@@ -116,7 +115,7 @@ else ifeq ($(ARCH),x86_64) ...@@ -116,7 +115,7 @@ else ifeq ($(ARCH),x86_64)
QEMU_ARCH := x86_64 QEMU_ARCH := x86_64
KERNEL_ARCH := x86_64 KERNEL_ARCH := x86_64
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine q35,accel=kvm QEMU_MACHINE := -cpu host -machine q35,accel=kvm
else else
QEMU_MACHINE := -cpu Skylake-Server -machine q35 QEMU_MACHINE := -cpu Skylake-Server -machine q35
...@@ -126,7 +125,7 @@ else ifeq ($(ARCH),i686) ...@@ -126,7 +125,7 @@ else ifeq ($(ARCH),i686)
QEMU_ARCH := i386 QEMU_ARCH := i386
KERNEL_ARCH := x86 KERNEL_ARCH := x86
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/x86/boot/bzImage
ifeq ($(subst i686,x86_64,$(CBUILD)),$(CHOST)) ifeq ($(subst x86_64,i686,$(HOST_ARCH)),$(ARCH))
QEMU_MACHINE := -cpu host -machine q35,accel=kvm QEMU_MACHINE := -cpu host -machine q35,accel=kvm
else else
QEMU_MACHINE := -cpu coreduo -machine q35 QEMU_MACHINE := -cpu coreduo -machine q35
...@@ -136,7 +135,7 @@ else ifeq ($(ARCH),mips64) ...@@ -136,7 +135,7 @@ else ifeq ($(ARCH),mips64)
QEMU_ARCH := mips64 QEMU_ARCH := mips64
KERNEL_ARCH := mips KERNEL_ARCH := mips
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine malta,accel=kvm QEMU_MACHINE := -cpu host -machine malta,accel=kvm
CFLAGS += -EB CFLAGS += -EB
else else
...@@ -147,7 +146,7 @@ else ifeq ($(ARCH),mips64el) ...@@ -147,7 +146,7 @@ else ifeq ($(ARCH),mips64el)
QEMU_ARCH := mips64el QEMU_ARCH := mips64el
KERNEL_ARCH := mips KERNEL_ARCH := mips
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine malta,accel=kvm QEMU_MACHINE := -cpu host -machine malta,accel=kvm
CFLAGS += -EL CFLAGS += -EL
else else
...@@ -158,7 +157,7 @@ else ifeq ($(ARCH),mips) ...@@ -158,7 +157,7 @@ else ifeq ($(ARCH),mips)
QEMU_ARCH := mips QEMU_ARCH := mips
KERNEL_ARCH := mips KERNEL_ARCH := mips
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine malta,accel=kvm QEMU_MACHINE := -cpu host -machine malta,accel=kvm
CFLAGS += -EB CFLAGS += -EB
else else
...@@ -169,7 +168,7 @@ else ifeq ($(ARCH),mipsel) ...@@ -169,7 +168,7 @@ else ifeq ($(ARCH),mipsel)
QEMU_ARCH := mipsel QEMU_ARCH := mipsel
KERNEL_ARCH := mips KERNEL_ARCH := mips
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host -machine malta,accel=kvm QEMU_MACHINE := -cpu host -machine malta,accel=kvm
CFLAGS += -EL CFLAGS += -EL
else else
...@@ -180,7 +179,7 @@ else ifeq ($(ARCH),powerpc64le) ...@@ -180,7 +179,7 @@ else ifeq ($(ARCH),powerpc64le)
QEMU_ARCH := ppc64 QEMU_ARCH := ppc64
KERNEL_ARCH := powerpc KERNEL_ARCH := powerpc
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host,accel=kvm -machine pseries QEMU_MACHINE := -cpu host,accel=kvm -machine pseries
else else
QEMU_MACHINE := -machine pseries QEMU_MACHINE := -machine pseries
...@@ -190,7 +189,7 @@ else ifeq ($(ARCH),powerpc) ...@@ -190,7 +189,7 @@ else ifeq ($(ARCH),powerpc)
QEMU_ARCH := ppc QEMU_ARCH := ppc
KERNEL_ARCH := powerpc KERNEL_ARCH := powerpc
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/powerpc/boot/uImage KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/arch/powerpc/boot/uImage
ifeq ($(CHOST),$(CBUILD)) ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host,accel=kvm -machine ppce500 QEMU_MACHINE := -cpu host,accel=kvm -machine ppce500
else else
QEMU_MACHINE := -machine ppce500 QEMU_MACHINE := -machine ppce500
...@@ -200,10 +199,11 @@ else ifeq ($(ARCH),m68k) ...@@ -200,10 +199,11 @@ else ifeq ($(ARCH),m68k)
QEMU_ARCH := m68k QEMU_ARCH := m68k
KERNEL_ARCH := m68k KERNEL_ARCH := m68k
KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux KERNEL_BZIMAGE := $(KERNEL_BUILD_PATH)/vmlinux
ifeq ($(CHOST),$(CBUILD)) KERNEL_CMDLINE := $(shell sed -n 's/CONFIG_CMDLINE=\(.*\)/\1/p' arch/m68k.config)
QEMU_MACHINE := -cpu host,accel=kvm -machine q800 ifeq ($(HOST_ARCH),$(ARCH))
QEMU_MACHINE := -cpu host,accel=kvm -machine q800 -smp 1 -append $(KERNEL_CMDLINE)
else else
QEMU_MACHINE := -machine q800 QEMU_MACHINE := -machine q800 -smp 1 -append $(KERNEL_CMDLINE)
endif endif
else else
$(error I only build: x86_64, i686, arm, armeb, aarch64, aarch64_be, mips, mipsel, mips64, mips64el, powerpc64le, powerpc, m68k) $(error I only build: x86_64, i686, arm, armeb, aarch64, aarch64_be, mips, mipsel, mips64, mips64el, powerpc64le, powerpc, m68k)
...@@ -238,14 +238,14 @@ $(BUILD_PATH)/init-cpio-spec.txt: ...@@ -238,14 +238,14 @@ $(BUILD_PATH)/init-cpio-spec.txt:
echo "nod /dev/console 644 0 0 c 5 1" >> $@ echo "nod /dev/console 644 0 0 c 5 1" >> $@
echo "dir /bin 755 0 0" >> $@ echo "dir /bin 755 0 0" >> $@
echo "file /bin/iperf3 $(IPERF_PATH)/src/iperf3 755 0 0" >> $@ echo "file /bin/iperf3 $(IPERF_PATH)/src/iperf3 755 0 0" >> $@
echo "file /bin/wg $(WIREGUARD_TOOLS_PATH)/src/tools/wg 755 0 0" >> $@ echo "file /bin/wg $(WIREGUARD_TOOLS_PATH)/src/wg 755 0 0" >> $@
echo "file /bin/bash $(BASH_PATH)/bash 755 0 0" >> $@ echo "file /bin/bash $(BASH_PATH)/bash 755 0 0" >> $@
echo "file /bin/ip $(IPROUTE2_PATH)/ip/ip 755 0 0" >> $@ echo "file /bin/ip $(IPROUTE2_PATH)/ip/ip 755 0 0" >> $@
echo "file /bin/ss $(IPROUTE2_PATH)/misc/ss 755 0 0" >> $@ echo "file /bin/ss $(IPROUTE2_PATH)/misc/ss 755 0 0" >> $@
echo "file /bin/ping $(IPUTILS_PATH)/ping 755 0 0" >> $@ echo "file /bin/ping $(IPUTILS_PATH)/ping 755 0 0" >> $@
echo "file /bin/ncat $(NMAP_PATH)/ncat/ncat 755 0 0" >> $@ echo "file /bin/ncat $(NMAP_PATH)/ncat/ncat 755 0 0" >> $@
echo "file /bin/xtables-multi $(IPTABLES_PATH)/iptables/xtables-multi 755 0 0" >> $@ echo "file /bin/xtables-legacy-multi $(IPTABLES_PATH)/iptables/xtables-legacy-multi 755 0 0" >> $@
echo "slink /bin/iptables xtables-multi 777 0 0" >> $@ echo "slink /bin/iptables xtables-legacy-multi 777 0 0" >> $@
echo "slink /bin/ping6 ping 777 0 0" >> $@ echo "slink /bin/ping6 ping 777 0 0" >> $@
echo "dir /lib 755 0 0" >> $@ echo "dir /lib 755 0 0" >> $@
echo "file /lib/libc.so $(MUSL_PATH)/lib/libc.so 755 0 0" >> $@ echo "file /lib/libc.so $(MUSL_PATH)/lib/libc.so 755 0 0" >> $@
...@@ -260,8 +260,8 @@ $(KERNEL_BUILD_PATH)/.config: kernel.config arch/$(ARCH).config ...@@ -260,8 +260,8 @@ $(KERNEL_BUILD_PATH)/.config: kernel.config arch/$(ARCH).config
cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config $(KERNEL_BUILD_PATH)/minimal.config cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config $(KERNEL_BUILD_PATH)/minimal.config
$(if $(findstring yes,$(DEBUG_KERNEL)),cp debug.config $(KERNEL_BUILD_PATH) && cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config debug.config,) $(if $(findstring yes,$(DEBUG_KERNEL)),cp debug.config $(KERNEL_BUILD_PATH) && cd $(KERNEL_BUILD_PATH) && ARCH=$(KERNEL_ARCH) $(KERNEL_PATH)/scripts/kconfig/merge_config.sh -n $(KERNEL_BUILD_PATH)/.config debug.config,)
$(KERNEL_BZIMAGE): $(KERNEL_BUILD_PATH)/.config $(BUILD_PATH)/init-cpio-spec.txt $(MUSL_PATH)/lib/libc.so $(IPERF_PATH)/src/iperf3 $(IPUTILS_PATH)/ping $(BASH_PATH)/bash $(IPROUTE2_PATH)/misc/ss $(IPROUTE2_PATH)/ip/ip $(IPTABLES_PATH)/iptables/xtables-multi $(NMAP_PATH)/ncat/ncat $(WIREGUARD_TOOLS_PATH)/src/tools/wg $(BUILD_PATH)/init ../netns.sh $(WIREGUARD_SOURCES) $(KERNEL_BZIMAGE): $(KERNEL_BUILD_PATH)/.config $(BUILD_PATH)/init-cpio-spec.txt $(MUSL_PATH)/lib/libc.so $(IPERF_PATH)/src/iperf3 $(IPUTILS_PATH)/ping $(BASH_PATH)/bash $(IPROUTE2_PATH)/misc/ss $(IPROUTE2_PATH)/ip/ip $(IPTABLES_PATH)/iptables/xtables-legacy-multi $(NMAP_PATH)/ncat/ncat $(WIREGUARD_TOOLS_PATH)/src/wg $(BUILD_PATH)/init ../netns.sh $(WIREGUARD_SOURCES)
$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) CC="$(NOPIE_GCC)" $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
$(BUILD_PATH)/include/linux/.installed: | $(KERNEL_BUILD_PATH)/.config $(BUILD_PATH)/include/linux/.installed: | $(KERNEL_BUILD_PATH)/.config
$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) INSTALL_HDR_PATH=$(BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) headers_install $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) INSTALL_HDR_PATH=$(BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) headers_install
...@@ -280,7 +280,7 @@ $(BUILD_PATH)/include/.installed: $(MUSL_PATH)/lib/libc.so ...@@ -280,7 +280,7 @@ $(BUILD_PATH)/include/.installed: $(MUSL_PATH)/lib/libc.so
$(MUSL_CC): $(MUSL_PATH)/lib/libc.so $(MUSL_CC): $(MUSL_PATH)/lib/libc.so
sh $(MUSL_PATH)/tools/musl-gcc.specs.sh $(BUILD_PATH)/include $(MUSL_PATH)/lib /lib/ld-linux.so.1 > $(BUILD_PATH)/musl-gcc.specs sh $(MUSL_PATH)/tools/musl-gcc.specs.sh $(BUILD_PATH)/include $(MUSL_PATH)/lib /lib/ld-linux.so.1 > $(BUILD_PATH)/musl-gcc.specs
printf '#!/bin/sh\nexec "$(REAL_CC)" --specs="$(BUILD_PATH)/musl-gcc.specs" -fno-stack-protector -no-pie "$$@"\n' > $(BUILD_PATH)/musl-gcc printf '#!/bin/sh\nexec "$(REAL_CC)" --specs="$(BUILD_PATH)/musl-gcc.specs" "$$@"\n' > $(BUILD_PATH)/musl-gcc
chmod +x $(BUILD_PATH)/musl-gcc chmod +x $(BUILD_PATH)/musl-gcc
$(IPERF_PATH)/.installed: $(IPERF_TAR) $(IPERF_PATH)/.installed: $(IPERF_TAR)
...@@ -291,7 +291,7 @@ $(IPERF_PATH)/.installed: $(IPERF_TAR) ...@@ -291,7 +291,7 @@ $(IPERF_PATH)/.installed: $(IPERF_TAR)
touch $@ touch $@
$(IPERF_PATH)/src/iperf3: | $(IPERF_PATH)/.installed $(USERSPACE_DEPS) $(IPERF_PATH)/src/iperf3: | $(IPERF_PATH)/.installed $(USERSPACE_DEPS)
cd $(IPERF_PATH) && CFLAGS="$(CFLAGS) -D_GNU_SOURCE" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared cd $(IPERF_PATH) && CFLAGS="$(CFLAGS) -D_GNU_SOURCE" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --with-openssl=no
$(MAKE) -C $(IPERF_PATH) $(MAKE) -C $(IPERF_PATH)
$(STRIP) -s $@ $(STRIP) -s $@
...@@ -308,8 +308,8 @@ $(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR) ...@@ -308,8 +308,8 @@ $(WIREGUARD_TOOLS_PATH)/.installed: $(WIREGUARD_TOOLS_TAR)
flock -s $<.lock tar -C $(BUILD_PATH) -xf $< flock -s $<.lock tar -C $(BUILD_PATH) -xf $<
touch $@ touch $@
$(WIREGUARD_TOOLS_PATH)/src/tools/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS) $(WIREGUARD_TOOLS_PATH)/src/wg: | $(WIREGUARD_TOOLS_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS)
LDFLAGS="$(LDFLAGS) -L$(LIBMNL_PATH)/src/.libs" $(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src/tools LIBMNL_CFLAGS="-I$(LIBMNL_PATH)/include" LIBMNL_LDLIBS="-lmnl" wg LDFLAGS="$(LDFLAGS) -L$(LIBMNL_PATH)/src/.libs" $(MAKE) -C $(WIREGUARD_TOOLS_PATH)/src LIBMNL_CFLAGS="-I$(LIBMNL_PATH)/include" LIBMNL_LDLIBS="-lmnl" wg
$(STRIP) -s $@ $(STRIP) -s $@
$(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS) $(BUILD_PATH)/init: init.c | $(USERSPACE_DEPS)
...@@ -323,7 +323,8 @@ $(IPUTILS_PATH)/.installed: $(IPUTILS_TAR) ...@@ -323,7 +323,8 @@ $(IPUTILS_PATH)/.installed: $(IPUTILS_TAR)
touch $@ touch $@
$(IPUTILS_PATH)/ping: | $(IPUTILS_PATH)/.installed $(USERSPACE_DEPS) $(IPUTILS_PATH)/ping: | $(IPUTILS_PATH)/.installed $(USERSPACE_DEPS)
$(MAKE) -C $(IPUTILS_PATH) USE_CAP=no USE_IDN=no USE_NETTLE=no USE_CRYPTO=no ping sed -i /atexit/d $(IPUTILS_PATH)/ping.c
cd $(IPUTILS_PATH) && $(CC) $(CFLAGS) -std=c99 -o $@ ping.c ping_common.c ping6_common.c iputils_common.c -D_GNU_SOURCE -D'IPUTILS_VERSION(f)=f' -lresolv $(LDFLAGS)
$(STRIP) -s $@ $(STRIP) -s $@
$(BASH_PATH)/.installed: $(BASH_TAR) $(BASH_PATH)/.installed: $(BASH_TAR)
...@@ -357,7 +358,7 @@ $(IPTABLES_PATH)/.installed: $(IPTABLES_TAR) ...@@ -357,7 +358,7 @@ $(IPTABLES_PATH)/.installed: $(IPTABLES_TAR)
sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure sed -i -e "/nfnetlink=[01]/s:=[01]:=0:" -e "/nfconntrack=[01]/s:=[01]:=0:" $(IPTABLES_PATH)/configure
touch $@ touch $@
$(IPTABLES_PATH)/iptables/xtables-multi: | $(IPTABLES_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS) $(IPTABLES_PATH)/iptables/xtables-legacy-multi: | $(IPTABLES_PATH)/.installed $(LIBMNL_PATH)/src/.libs/libmnl.a $(USERSPACE_DEPS)
cd $(IPTABLES_PATH) && PKG_CONFIG_LIBDIR="$(LIBMNL_PATH)" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --disable-nftables --disable-bpf-compiler --disable-nfsynproxy --disable-libipq --with-kernel=$(BUILD_PATH)/include cd $(IPTABLES_PATH) && PKG_CONFIG_LIBDIR="$(LIBMNL_PATH)" ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --disable-nftables --disable-bpf-compiler --disable-nfsynproxy --disable-libipq --with-kernel=$(BUILD_PATH)/include
$(MAKE) -C $(IPTABLES_PATH) $(MAKE) -C $(IPTABLES_PATH)
$(STRIP) -s $@ $(STRIP) -s $@
...@@ -368,8 +369,9 @@ $(NMAP_PATH)/.installed: $(NMAP_TAR) ...@@ -368,8 +369,9 @@ $(NMAP_PATH)/.installed: $(NMAP_TAR)
touch $@ touch $@
$(NMAP_PATH)/ncat/ncat: | $(NMAP_PATH)/.installed $(USERSPACE_DEPS) $(NMAP_PATH)/ncat/ncat: | $(NMAP_PATH)/.installed $(USERSPACE_DEPS)
cd $(NMAP_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --without-ndiff --without-zenmap --without-nping --with-libpcap=included --with-libpcre=included --with-libdnet=included --without-liblua --with-liblinear=included --without-nmap-update --without-openssl --with-pcap=linux cd $(NMAP_PATH) && ./configure --prefix=/ $(CROSS_COMPILE_FLAG) --enable-static --disable-shared --without-ndiff --without-zenmap --without-nping --with-libpcap=included --with-libpcre=included --with-libdnet=included --without-liblua --with-liblinear=included --without-nmap-update --without-openssl --with-pcap=linux --without-libssh
$(MAKE) -C $(NMAP_PATH) build-ncat $(MAKE) -C $(NMAP_PATH)/libpcap
$(MAKE) -C $(NMAP_PATH)/ncat
$(STRIP) -s $@ $(STRIP) -s $@
clean: clean:
...@@ -379,7 +381,7 @@ distclean: clean ...@@ -379,7 +381,7 @@ distclean: clean
rm -rf $(DISTFILES_PATH) rm -rf $(DISTFILES_PATH)
menuconfig: $(KERNEL_BUILD_PATH)/.config menuconfig: $(KERNEL_BUILD_PATH)/.config
$(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) CC="$(NOPIE_GCC)" menuconfig $(MAKE) -C $(KERNEL_PATH) O=$(KERNEL_BUILD_PATH) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) menuconfig
.PHONY: qemu build clean distclean menuconfig .PHONY: qemu build clean distclean menuconfig
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
CONFIG_MMU=y CONFIG_MMU=y
CONFIG_M68KCLASSIC=y
CONFIG_M68040=y CONFIG_M68040=y
CONFIG_MAC=y CONFIG_MAC=y
CONFIG_SERIAL_PMACZILOG=y CONFIG_SERIAL_PMACZILOG=y
CONFIG_SERIAL_PMACZILOG_TTYS=y CONFIG_SERIAL_PMACZILOG_TTYS=y
CONFIG_SERIAL_PMACZILOG_CONSOLE=y CONFIG_SERIAL_PMACZILOG_CONSOLE=y
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1" CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1"
CONFIG_FRAME_WARN=1024 CONFIG_FRAME_WARN=1024
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <sys/reboot.h> #include <sys/reboot.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/sysmacros.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/version.h> #include <linux/version.h>
......
...@@ -39,6 +39,7 @@ CONFIG_PRINTK=y ...@@ -39,6 +39,7 @@ CONFIG_PRINTK=y
CONFIG_KALLSYMS=y CONFIG_KALLSYMS=y
CONFIG_BUG=y CONFIG_BUG=y
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
CONFIG_JUMP_LABEL=y
CONFIG_EMBEDDED=n CONFIG_EMBEDDED=n
CONFIG_BASE_FULL=y CONFIG_BASE_FULL=y
CONFIG_FUTEX=y CONFIG_FUTEX=y
...@@ -55,6 +56,7 @@ CONFIG_NO_HZ_IDLE=y ...@@ -55,6 +56,7 @@ CONFIG_NO_HZ_IDLE=y
CONFIG_NO_HZ_FULL=n CONFIG_NO_HZ_FULL=n
CONFIG_HZ_PERIODIC=n CONFIG_HZ_PERIODIC=n
CONFIG_HIGH_RES_TIMERS=y CONFIG_HIGH_RES_TIMERS=y
CONFIG_COMPAT_32BIT_TIME=y
CONFIG_ARCH_RANDOM=y CONFIG_ARCH_RANDOM=y
CONFIG_FILE_LOCKING=y CONFIG_FILE_LOCKING=y
CONFIG_POSIX_TIMERS=y CONFIG_POSIX_TIMERS=y
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment