gnu: qemu-for-american-fuzzy-lop: Fix build.
[jackhill/guix/guix.git] / gnu / packages / patches / qemu-glibc-2.30.patch
1 This patch was taken from NixOS
2 https://raw.githubusercontent.com/Mindavi/nixpkgs/1a737743a829746e48f4869ac517ff29c23c9d09/pkgs/tools/security/afl/qemu-patches/syscall-glibc2_30.diff
3 It is based on an unmerged patch against american-fuzzy-lop and was
4 never merged upstream because the author was unable to sign Google's CLA.
5 Based on https://github.com/google/AFL/commit/6c917e3d63a2a0685d58c3518524f9615b001893.patch
6
7 --- qemu-2.10.0-clean/linux-user/syscall.c 2020-03-12 18:47:47.898592169 +0100
8 +++ qemu-2.10.0/linux-user/syscall.c 2020-03-13 09:13:42.461809699 +0100
9 @@ -34,6 +34,7 @@
10 #include <sys/resource.h>
11 #include <sys/swap.h>
12 #include <linux/capability.h>
13 +#include <linux/sockios.h> // https://lkml.org/lkml/2019/6/3/988
14 #include <sched.h>
15 #include <sys/timex.h>
16 #ifdef __ia64__
17 @@ -256,7 +257,9 @@ static type name (type1 arg1,type2 arg2,
18 #endif
19
20 #ifdef __NR_gettid
21 -_syscall0(int, gettid)
22 +// taken from https://patchwork.kernel.org/patch/10862231/
23 +#define __NR_sys_gettid __NR_gettid
24 +_syscall0(int, sys_gettid)
25 #else
26 /* This is a replacement for the host gettid() and must return a host
27 errno. */
28 @@ -6219,7 +6222,7 @@ static void *clone_func(void *arg)
29 cpu = ENV_GET_CPU(env);
30 thread_cpu = cpu;
31 ts = (TaskState *)cpu->opaque;
32 - info->tid = gettid();
33 + info->tid = sys_gettid();
34 task_settid(ts);
35 if (info->child_tidptr)
36 put_user_u32(info->tid, info->child_tidptr);
37 @@ -6363,9 +6366,9 @@ static int do_fork(CPUArchState *env, un
38 mapping. We can't repeat the spinlock hack used above because
39 the child process gets its own copy of the lock. */
40 if (flags & CLONE_CHILD_SETTID)
41 - put_user_u32(gettid(), child_tidptr);
42 + put_user_u32(sys_gettid(), child_tidptr);
43 if (flags & CLONE_PARENT_SETTID)
44 - put_user_u32(gettid(), parent_tidptr);
45 + put_user_u32(sys_gettid(), parent_tidptr);
46 ts = (TaskState *)cpu->opaque;
47 if (flags & CLONE_SETTLS)
48 cpu_set_tls (env, newtls);
49 @@ -11402,7 +11405,7 @@ abi_long do_syscall(void *cpu_env, int n
50 break;
51 #endif
52 case TARGET_NR_gettid:
53 - ret = get_errno(gettid());
54 + ret = get_errno(sys_gettid());
55 break;
56 #ifdef TARGET_NR_readahead
57 case TARGET_NR_readahead: