PRE(sys_ioctl)
{
*flags |= SfMayBlock;
- // @todo PJF presumably the presence of ARG3 depends on ARG2
PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3);
PRE_REG_READ3(int, "ioctl",
int, fd, unsigned long, request, unsigned long, arg);
switch (ARG2 /* request */) {
/* Handle specific ioctls which pass structures which may have pointers to other
buffers */
- case VKI_FIODGNAME:
- // #define FIODGNAME _IOW('f', 120, struct fiodgname_arg) /* get dev. name */
- // has a regression test
- if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_fiodgname_arg))) {
- struct vki_fiodgname_arg* data = (struct vki_fiodgname_arg*)(Addr)ARG3;
- PRE_FIELD_READ("ioctl(FIODGNAME).len", data->len);
- PRE_FIELD_READ("ioctl(FIODGNAME).buf", data->buf);
- PRE_MEM_WRITE("ioctl(FIODGNAME).buf", (Addr)data->buf, data->len);
- }
- break;
- // The block below is from Ryan Stone
- // https://bitbucket.org/rysto32/valgrind-freebsd/commits/5323c22be9f6c71a00e842c3ddfa1fa8a7feb279
- case VKI_SIOCGIFMEDIA:
- // #define SIOCGIFMEDIA _IOWR('i', 56, struct ifmediareq) /* get net media */
- // test with "ifconfig -m"
- if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_ifmediareq))) {
- struct vki_ifmediareq* imr = (struct vki_ifmediareq*)ARG3;
- if (imr->ifm_ulist) {
- PRE_MEM_WRITE("ioctl(SIOCGIFMEDIA).ifm_ulist",
- (Addr)(imr->ifm_ulist), imr->ifm_count * sizeof(int));
- }
- }
- break;
-
- case VKI_PCIOCGETCONF:
- // #define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io)
- // test with "pciconf -l"
- if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_pci_conf_io))) {
- struct vki_pci_conf_io* pci = (struct vki_pci_conf_io*)ARG3;
- PRE_MEM_READ("ioctl(PCIOCGETCONF).patterns",
- (Addr)(pci->patterns), pci->pat_buf_len);
- PRE_MEM_WRITE("ioctl(PCIOCGETCONF).matches",
- (Addr)(pci->matches), pci->match_buf_len);
+ case VKI_BIOCSETF:
+ // #define BIOCSETF _IOW('B', 103, struct bpf_program)
+ // test with "usbdump" (as root)
+ if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_bpf_program))) {
+ struct vki_bpf_program* fp = (struct vki_bpf_program*)ARG3;
+ PRE_FIELD_READ("ioctl(BIOCSETF).bf_len", fp->bf_len);
+ PRE_FIELD_READ("ioctl(BIOCSETF).bf_insns", fp->bf_insns);
+ PRE_MEM_READ("ioctl(BIOCSETF).bf_insns",
+ (Addr)(fp->bf_insns), fp->bf_len*sizeof(struct vki_bpf_insn));
}
break;
case VKI_CAMIOCOMMAND:
}
}
break;
+ case VKI_FIODGNAME:
+ // #define FIODGNAME _IOW('f', 120, struct fiodgname_arg) /* get dev. name */
+ // has a regression test
+ if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_fiodgname_arg))) {
+ struct vki_fiodgname_arg* data = (struct vki_fiodgname_arg*)(Addr)ARG3;
+ PRE_FIELD_READ("ioctl(FIODGNAME).len", data->len);
+ PRE_FIELD_READ("ioctl(FIODGNAME).buf", data->buf);
+ PRE_MEM_WRITE("ioctl(FIODGNAME).buf", (Addr)data->buf, data->len);
+ }
+ break;
case VKI_SIOCGIFCONF:
// #define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */
// test with "traceroute www.siemens.com" (as root)
PRE_MEM_WRITE("ioctl(SIOCGIFCONF).buf", (Addr)ifc->ifc_ifcu.ifcu_req, ifc->ifc_len);
}
break;
+ case VKI_SIOCGIFMEDIA:
+ // #define SIOCGIFMEDIA _IOWR('i', 56, struct ifmediareq) /* get net media */
+ // test with "ifconfig -m"
+ if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_ifmediareq))) {
+ struct vki_ifmediareq* imr = (struct vki_ifmediareq*)ARG3;
+ if (imr->ifm_ulist) {
+ PRE_MEM_WRITE("ioctl(SIOCGIFMEDIA).ifm_ulist",
+ (Addr)(imr->ifm_ulist), imr->ifm_count * sizeof(int));
+ }
+ }
+ break;
case VKI_SIOCGIFSTATUS:
// #define SIOCGIFSTATUS _IOWR('i', 59, struct ifstat) /* get IF status */
// test with "ifconfig -a"
PRE_MEM_WRITE("ioctl(SIOCGIFSTATUS).ascii", (Addr)data->ascii, sizeof(data->ascii));
}
break;
+ case VKI_PCIOCGETCONF:
+ // #define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io)
+ // test with "pciconf -l"
+ if (ARG3 && ML_(safe_to_deref)((const void*)ARG3, sizeof(struct vki_pci_conf_io))) {
+ struct vki_pci_conf_io* pci = (struct vki_pci_conf_io*)ARG3;
+ PRE_MEM_READ("ioctl(PCIOCGETCONF).patterns",
+ (Addr)(pci->patterns), pci->pat_buf_len);
+ PRE_MEM_WRITE("ioctl(PCIOCGETCONF).matches",
+ (Addr)(pci->matches), pci->match_buf_len);
+ }
+ break;
default:
ML_(PRE_unknown_ioctl)(tid, ARG2, ARG3);
break;
//----------------------------------------------------------------------
-// sys/types.h
+// From sys/types.h
//----------------------------------------------------------------------
+typedef unsigned char vki_u_char;
+typedef unsigned short vki_u_short;
+typedef unsigned int vki_u_int;
+typedef unsigned long vki_u_long;
+
typedef vki_uint8_t vki_u_int8_t;
typedef vki_uint16_t vki_u_int16_t;
typedef vki_uint32_t vki_u_int32_t;
// From sys/termios.h
//----------------------------------------------------------------------
-#if 0
-#define VKI_TCGETS 0x5401
-#define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
-#define VKI_TCSETSW 0x5403
-#define VKI_TCSETSF 0x5404
-#define VKI_TCGETA 0x5405 y
-#define VKI_TCSETA 0x5406 y
-#define VKI_TCSETAW 0x5407 y
-#define VKI_TCSETAF 0x5408 y
-#define VKI_TCSBRK 0x5409
-#define VKI_TCXONC 0x540A
-#define VKI_TCFLSH 0x540B y
-#define VKI_TIOCSCTTY 0x540E
-#define VKI_TIOCGPGRP 0x540F y
-#define VKI_TIOCSPGRP 0x5410 y
-#define VKI_TIOCOUTQ 0x5411
-#define VKI_TIOCGWINSZ 0x5413 y
-#define VKI_TIOCSWINSZ 0x5414 y
-#define VKI_TIOCMGET 0x5415 y
-#define VKI_TIOCMBIS 0x5416 y
-#define VKI_TIOCMBIC 0x5417 y
-#define VKI_TIOCMSET 0x5418 y
-#define VKI_FIONREAD 0x541B
-#define VKI_TIOCLINUX 0x541C
-#define VKI_FIONBIO 0x5421
-#define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
-#define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
-#define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
-
-#define VKI_FIOASYNC 0x5452
-#define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
-
-#define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
-#endif
-
-#define VKI_TIOCFLUSH _VKI_IOW('t', 16, int);
-#define VKI_TIOCGETA _VKI_IOR('t', 19, struct vki_termios) /* get termios */
-#define VKI_TIOCSETA _VKI_IOR('t', 20, struct vki_termios) /* set termios */
-#define VKI_TIOCSETAW _VKI_IOR('t', 21, struct vki_termios) /* drain,set */
-#define VKI_TIOCSETAF _VKI_IOR('t', 22, struct vki_termios) /* flush,set */
+#define VKI_TIOCFLUSH _VKI_IOW('t', 16, int);
+#define VKI_TIOCGETA _VKI_IOR('t', 19, struct vki_termios) /* get termios */
+#define VKI_TIOCSETA _VKI_IOR('t', 20, struct vki_termios) /* set termios */
+#define VKI_TIOCSETAW _VKI_IOR('t', 21, struct vki_termios) /* drain,set */
+#define VKI_TIOCSETAF _VKI_IOR('t', 22, struct vki_termios) /* flush,set */
-#define _VKI_TIOCPTMASTER _VKI_IO('t', 28) /* pts master validation */
+#define _VKI_TIOCPTMASTER _VKI_IO('t', 28) /* pts master validation */
#define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) /* set window size */
#define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) /* get window size */
};
#define VKI_FIODGNAME _VKI_IOW('f', 120, struct vki_fiodgname_arg) /* get dev. name */
-// See syswrap-freebsd.c PRE/POST(sys_ioctl)
+//----------------------------------------------------------------------
+// From net/bpf.h
+//----------------------------------------------------------------------
+
+struct vki_bpf_program {
+ vki_u_int bf_len;
+ struct vki_bpf_insn *bf_insns;
+};
+
+typedef vki_u_int32_t vki_bpf_u_int32;
+
+struct vki_bpf_insn {
+ u_short code;
+ u_char jt;
+ u_char jf;
+ vki_bpf_u_int32 k;
+};
+
+
+#define VKI_BIOCSETF _VKI_IOW('B', 103, struct vki_bpf_program)
+
//----------------------------------------------------------------------
// From net/if.h
//----------------------------------------------------------------------
};
struct vki_ifreq_nv_req {
- u_int buf_length; /* Total size of buffer,
+ vki_u_int buf_length; /* Total size of buffer,
u_int for ABI struct ifreq */
- u_int length; /* Length of the filled part */
+ vki_u_int length; /* Length of the filled part */
void *buffer; /* Buffer itself, containing packed nv */
};
int ifru_media;
__vki_caddr_t ifru_data;
int ifru_cap[2];
- u_int ifru_fib;
- u_char ifru_vlan_pcp;
+ vki_u_int ifru_fib;
+ vki_u_char ifru_vlan_pcp;
struct vki_ifreq_nv_req ifru_nv;
} ifr_ifru;
};
#define VKI_PROC_WXMAP_STATUS 22
struct vki_procctl_reaper_status {
- u_int rs_flags;
- u_int rs_children;
- u_int rs_descendants;
+ vki_u_int rs_flags;
+ vki_u_int rs_children;
+ vki_u_int rs_descendants;
vki_pid_t rs_reaper;
vki_pid_t rs_pid;
- u_int rs_pad0[15];
+ vki_u_int rs_pad0[15];
};
struct vki_procctl_reaper_pidinfo;
struct vki_procctl_reaper_pids {
- u_int rp_count;
- u_int rp_pad0[15];
+ vki_u_int rp_count;
+ vki_u_int rp_pad0[15];
struct vki_procctl_reaper_pidinfo *rp_pids;
};
struct vki_procctl_reaper_kill {
int rk_sig;
- u_int rk_flags;
+ vki_u_int rk_flags;
vki_pid_t rk_subtree;
- u_int rk_killed;
+ vki_u_int rk_killed;
vki_pid_t rk_fpid;
- u_int rk_pad0[15];
+ vki_u_int rk_pad0[15];
};
//----------------------------------------------------------------------