tests: add more checks of unknown ioctl command formatting
* tests/ioctl.c (main): Additional check for unknown ioctl command decoding. * tests/ioctl_evdev.c (main): Likewise. * tests/ioctl_dm.c: Include <linux/ioctl.h> for _IOC_SIZE and _IOC_NR. (main) <dummy_dm_ioctl1, dummy_dm_ioctl2, dummy_dm_arg>: New constants. Add more checks for unknown command formatting.
This commit is contained in:
parent
b00f54e881
commit
1ccc55eed2
@ -88,6 +88,10 @@ main(void )
|
||||
printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])"
|
||||
" = -1 EBADF (%m)\n");
|
||||
|
||||
(void) ioctl(-1, _IOC(_IOC_WRITE, 0xde, 0, 0), (kernel_ulong_t) -1ULL);
|
||||
printf("ioctl(-1, _IOC(_IOC_WRITE, 0xde, 0, 0), %#lx)"
|
||||
" = -1 EBADF (%m)\n", -1UL);
|
||||
|
||||
(void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
|
||||
printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x8), %p)"
|
||||
" = -1 EBADF (%m)\n", &data);
|
||||
|
@ -39,6 +39,7 @@
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <linux/ioctl.h>
|
||||
# include <linux/dm-ioctl.h>
|
||||
|
||||
# ifndef VERBOSE
|
||||
@ -160,6 +161,12 @@ print_dm_target_spec(struct dm_target_spec *ptr, uint32_t id)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static kernel_ulong_t dummy_dm_ioctl1 =
|
||||
_IOC(_IOC_READ, DM_IOCTL, 0, 0x1fff);
|
||||
static kernel_ulong_t dummy_dm_ioctl2 =
|
||||
_IOC(_IOC_READ|_IOC_WRITE, DM_IOCTL, 0xed, 0);
|
||||
static kernel_ulong_t dummy_dm_arg =
|
||||
(kernel_ulong_t) 0xbadc0dedda7a1057ULL;
|
||||
/* We can't check these properly for now */
|
||||
static struct args dummy_check_cmds_nodev[] = {
|
||||
{ ARG_STR(DM_REMOVE_ALL), false },
|
||||
@ -200,6 +207,16 @@ main(void)
|
||||
"-1 EBADF (%m)\n",
|
||||
DM_IOCTL, sizeof(int), dm_arg);
|
||||
|
||||
ioctl(-1, dummy_dm_ioctl1, 0);
|
||||
printf("ioctl(-1, _IOC(_IOC_READ, %#x, 0, %#x), 0) = -1 EBADF (%m)\n",
|
||||
DM_IOCTL, (unsigned int) _IOC_SIZE(dummy_dm_ioctl1));
|
||||
|
||||
ioctl(-1, dummy_dm_ioctl2, dummy_dm_arg);
|
||||
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, %#x, %#x, 0), %#lx) = "
|
||||
"-1 EBADF (%m)\n",
|
||||
DM_IOCTL, (unsigned int) _IOC_NR(dummy_dm_ioctl2),
|
||||
(unsigned long) dummy_dm_arg);
|
||||
|
||||
|
||||
/* DM_VERSION */
|
||||
/* Incorrect pointer */
|
||||
|
@ -274,6 +274,10 @@ main(void)
|
||||
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
|
||||
"_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)", lmagic);
|
||||
|
||||
ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0), lmagic);
|
||||
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
|
||||
"_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)", lmagic);
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user