From 440b26ec58c1da582a1b614a476a4b5f3abf43d0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 27 Sep 2024 16:02:43 +0200 Subject: sys/linux/test: add ELF binary seed Add a seed that creates and execs something that resembles an ELF binary. --- sys/linux/binfmt.txt | 4 ++-- sys/linux/test/execve_elf | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 sys/linux/test/execve_elf (limited to 'sys/linux') diff --git a/sys/linux/binfmt.txt b/sys/linux/binfmt.txt index 98a67336f..08938298c 100644 --- a/sys/linux/binfmt.txt +++ b/sys/linux/binfmt.txt @@ -105,7 +105,7 @@ type binfmt_elf64 binfmt_elf[int64, elf64_phdr, ELF64_PHDR_SIZE] type binfmt_elf[ADDR, PHDR, PHENTSIZE] { hdr elf_hdr[ADDR, PHENTSIZE] - phdr array[PHDR, 1:2] + phdr array[PHDR, 1:4] data array[int8] # Just to make the file of a non-trivial size. pad array[array[const[0, int64], 32], 0:10] @@ -130,7 +130,7 @@ type elf_hdr[ADDR, PHENTSIZE] { e_flags int32 e_ehsize int16 e_phentsize const[PHENTSIZE, int16] - e_phnum int16[1:2] + e_phnum len[binfmt_elf:phdr, int16] e_shentsize int16 e_shnum int16 e_shstrndx int16 diff --git a/sys/linux/test/execve_elf b/sys/linux/test/execve_elf new file mode 100644 index 000000000..71607fb23 --- /dev/null +++ b/sys/linux/test/execve_elf @@ -0,0 +1,5 @@ +r0 = syz_create_resource$binfmt(&AUTO='./file0\x00') +r1 = openat$binfmt(0xffffffffffffff9c, r0, 0x42, 0x1ff) +write$binfmt_elf64(r1, &AUTO={{AUTO, AUTO, AUTO, AUTO, 0x2, 0x1, 0x1, 0x3, 0x0, 0x2, 0x3e, 0x1, 0x100, 0x40, 0x200, 0x0, 0x40, AUTO, AUTO, 0x40, 0x2, 0x1}, [{0x1, 0x0, 0x0, 0x10000, 0x150, 0x10, 0x1000, 0x0}, {0x1, 0x0, 0x0, 0x20000, 0x200, 0x0, 0x2000, 0x10}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}], ""/0x1000, ["", "", ""]}, AUTO) +close(r1) +execveat$binfmt(0xffffffffffffff9c, r0, &AUTO={[], 0x0}, &AUTO={[], 0x0}, 0x0) -- cgit mrf-deployment