2 * SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
5 #include <linux/ioctl.h>
6 #include <linux/major.h>
13 static void ioctl_mangle_cmd(int childno
)
17 /* mangle the cmd by ORing up to 4 random bits */
18 for (i
=0; i
< (unsigned int)(rand() % 4); i
++)
19 shm
->a2
[childno
] |= 1L << (rand() % 32);
21 /* mangle the cmd by ANDing up to 4 random bits */
22 for (i
=0; i
< (unsigned int)(rand() % 4); i
++)
23 shm
->a2
[childno
] &= 1L << (rand() % 32);
26 static void ioctl_mangle_arg(int childno
)
28 /* the argument could mean anything, because ioctl sucks like that. */
30 shm
->a3
[childno
] = rand32();
32 shm
->a3
[childno
] = (unsigned long) get_non_null_address();
35 static void generic_sanitise_ioctl(int childno
)
38 ioctl_mangle_cmd(childno
);
40 ioctl_mangle_arg(childno
);
43 static void sanitise_ioctl(int childno
)
45 const struct ioctl_group
*grp
;
47 if (rand() % 100 == 0)
48 grp
= get_random_ioctl_group();
50 grp
= find_ioctl_group(shm
->a1
[childno
]);
53 ioctl_mangle_arg(childno
);
55 grp
->sanitise(grp
, childno
);
57 if (rand() % 100 == 0)
58 ioctl_mangle_cmd(childno
);
60 generic_sanitise_ioctl(childno
);
63 struct syscallentry syscall_ioctl
= {
70 .arg3type
= ARG_RANDPAGE
,
71 .sanitise
= sanitise_ioctl
,