From 52c1f8045c38bcce0229b2cc3c69b1cbe21eb629 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 18 Sep 2024 17:38:12 +0200 Subject: sys/linux: add syz_create_resource syz_create_resource allows to turn any value into a resource. Improve binfmt descriptions using syz_create_resource: we need to pass the same file name to write syscalls and execve. Use syz_create_resource to improve binfmt descriptions. --- sys/linux/binfmt.txt | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'sys/linux/binfmt.txt') diff --git a/sys/linux/binfmt.txt b/sys/linux/binfmt.txt index 3e86ab61a..d0e6b7b23 100644 --- a/sys/linux/binfmt.txt +++ b/sys/linux/binfmt.txt @@ -3,15 +3,33 @@ include include +include -execve(file ptr[in, filename], argv ptr[in, array[ptr[in, string]]], envp ptr[in, array[ptr[in, string]]]) -execveat(dirfd fd_dir, file ptr[in, filename], argv ptr[in, array[ptr[in, string]]], envp ptr[in, array[ptr[in, string]]], flags flags[at_flags]) +resource fd_binfmt[fd] +resource ptr_binfmt_file[intptr] -write$binfmt_script(fd fd, data ptr[in, binfmt_script], len bytesize[data]) -write$binfmt_misc(fd fd, data ptr[in, binfmt_misc], len bytesize[data]) -write$binfmt_aout(fd fd, data ptr[in, binfmt_aout], len bytesize[data]) -write$binfmt_elf32(fd fd, data ptr[in, binfmt_elf32], len bytesize[data]) -write$binfmt_elf64(fd fd, data ptr[in, binfmt_elf64], len bytesize[data]) +syz_create_resource$binfmt(file ptr[in, filename]) ptr_binfmt_file + +execve(file ptr[in, filename], argv ptr[in, argv_array], envp ptr[in, argv_array]) +execveat(dirfd fd_dir, file ptr[in, filename], argv ptr[in, argv_array], envp ptr[in, argv_array], flags flags[at_flags]) +execveat$binfmt(dirfd fd_dir, file ptr_binfmt_file, argv ptr[in, argv_array], envp ptr[in, argv_array], flags flags[at_flags]) + +openat$binfmt(fd const[AT_FDCWD], file ptr_binfmt_file, flags const[BINFMT_OPEN_FLAGS], mode const[0x1ff]) fd_binfmt + +write$binfmt_script(fd fd_binfmt, data ptr[in, binfmt_script], len bytesize[data]) +write$binfmt_misc(fd fd_binfmt, data ptr[in, binfmt_misc], len bytesize[data]) +write$binfmt_aout(fd fd_binfmt, data ptr[in, binfmt_aout], len bytesize[data]) +write$binfmt_elf32(fd fd_binfmt, data ptr[in, binfmt_elf32], len bytesize[data]) +write$binfmt_elf64(fd fd_binfmt, data ptr[in, binfmt_elf64], len bytesize[data]) + +close$binfmt(fd fd_binfmt) + +define BINFMT_OPEN_FLAGS O_WRONLY | O_CREAT + +argv_array { + args array[ptr[in, string]] + z const[0, intptr] +} [packed] binfmt_script { hdr stringnoz["#! "] -- cgit mrf-deployment