From d45d71be0607eb53a9bc39d0029a8e6ce96dbd3d Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 28 Aug 2017 00:39:15 +0000 Subject: [PATCH] Imply RVAL_DECODED when RVAL_IOCTL_PARSED is returned on entering Also, rename RVAL_IOCTL_PARSED to RVAL_IOCTL_DECODED as the latter is a more suitable name. * defs.h (RVAL_IOCTL_PARSED): Rename to RVAL_IOCTL_DECODED. * ioctl.c (ioctl_decode): Update comment. (SYS_FUNC(ioctl)): Replace RVAL_IOCTL_PARSED with RVAL_IOCTL_DECODED, add convertation of RVAL_IOCTL_DECODED to RVAL_DECODED. * block.c (block_ioctl): Replace RVAL_DECODED | RVAL_IOCTL_PARSED with RVAL_IOCTL_DECODED on entering. Replace RVAL_IOCTL_PARSED with RVAL_IOCTL_DECODED on exiting. * btrfs.c (btrfs_ioctl): Likewise. * evdev.c: Likewise. * file_ioctl.c: Likewise. * fs_x_ioctl.c: Likewise. * hdio.c: Likewise. * loop.c: Likewise. * mtd.c: Likewise. * nsfs.c: Likewise. * print_sg_req_info.c: Likewise. * ptp.c: Likewise. * rtc.c: Likewise. * scsi.c: Likewise. * sg_io_v3.c: Likewise. * sg_io_v4.c: Likewise. * sock.c: Likewise. * term.c: Likewise. * ubi.c: Likewise. * userfaultfd.c: Likewise. * dm.c (dm_known_ioctl): Return RVAL_IOCTL_DECODED on exiting and 0 on entering. Replace RVAL_IOCTL_PARSED with RVAL_IOCTL_DECODED on exiting. * v4l2.c: Likewise. Co-authored-by: Eugene Syromyatnikov --- block.c | 2 +- btrfs.c | 2 +- defs.h | 4 +- dm.c | 4 +- evdev.c | 44 +++++++++---------- file_ioctl.c | 2 +- fs_x_ioctl.c | 2 +- hdio.c | 2 +- ioctl.c | 38 ++++++++--------- loop.c | 2 +- mtd.c | 2 +- nsfs.c | 8 ++-- print_sg_req_info.c | 2 +- ptp.c | 2 +- rtc.c | 2 +- scsi.c | 6 +-- sg_io_v3.c | 10 ++--- sg_io_v4.c | 10 ++--- sock.c | 6 +-- term.c | 2 +- ubi.c | 2 +- userfaultfd.c | 8 ++-- v4l2.c | 100 +++++++++++++++++++++++--------------------- 23 files changed, 134 insertions(+), 128 deletions(-) diff --git a/block.c b/block.c index 06c5004c..4211e4f6 100644 --- a/block.c +++ b/block.c @@ -265,5 +265,5 @@ MPERS_PRINTER_DECL(int, block_ioctl, struct tcb *const tcp, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/btrfs.c b/btrfs.c index f4487d63..543acd7e 100644 --- a/btrfs.c +++ b/btrfs.c @@ -1345,6 +1345,6 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl, default: return RVAL_DECODED; }; - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #endif /* HAVE_LINUX_BTRFS_H */ diff --git a/defs.h b/defs.h index 72bee85e..93f09706 100644 --- a/defs.h +++ b/defs.h @@ -307,8 +307,8 @@ extern const struct xlat whence_codes[]; #define RVAL_NONE 040 /* Print nothing */ #define RVAL_DECODED 0100 /* syscall decoding finished */ -/* ioctl sub-parser successfully parsed (and printed) the argument */ -#define RVAL_IOCTL_PARSED 0200 +#define RVAL_IOCTL_DECODED 0200 /* ioctl sub-parser successfully decoded + the argument */ #define IOCTL_NUMBER_UNKNOWN 0 #define IOCTL_NUMBER_HANDLED 1 diff --git a/dm.c b/dm.c index 03216eb3..55efd92b 100644 --- a/dm.c +++ b/dm.c @@ -479,7 +479,7 @@ dm_known_ioctl(struct tcb *const tcp, const unsigned int code, } if (exiting(tcp) && syserror(tcp) && !ioc_changed) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; /* * device mapper code uses %d in some places and %u in another, but @@ -553,7 +553,7 @@ dm_known_ioctl(struct tcb *const tcp, const unsigned int code, skip: tprints("}"); - return RVAL_IOCTL_PARSED; + return entering(tcp) ? 0 : RVAL_IOCTL_DECODED; } int diff --git a/evdev.c b/evdev.c index 252fe5cb..fc7fc203 100644 --- a/evdev.c +++ b/evdev.c @@ -83,7 +83,7 @@ ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) struct_ff_effect ffe; if (umove_or_printaddr(tcp, arg, &ffe)) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{type="); printxval(evdev_ff_types, ffe.type, "FF_???"); @@ -94,7 +94,7 @@ ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) if (abbrev(tcp)) { tprints("...}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } tprintf("trigger={button=%" PRIu16 @@ -150,7 +150,7 @@ ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int @@ -184,7 +184,7 @@ abs_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); } - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int @@ -200,7 +200,7 @@ keycode_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) tprints("]"); } - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } # ifdef EVIOCGKEYCODE_V2 @@ -212,7 +212,7 @@ keycode_V2_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) struct input_keymap_entry ike; if (umove_or_printaddr(tcp, arg, &ike)) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{flags=%" PRIu8 ", len=%" PRIu8 ", ", @@ -237,7 +237,7 @@ keycode_V2_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } # endif /* EVIOCGKEYCODE_V2 */ @@ -258,7 +258,7 @@ getid_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) id.product, id.version); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int @@ -276,7 +276,7 @@ decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg, char decoded_arg[size]; if (umove_or_printaddr(tcp, arg, &decoded_arg)) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("["); @@ -300,7 +300,7 @@ decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg, tprints("]"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } # ifdef EVIOCGMTSLOTS @@ -313,13 +313,13 @@ mtslots_ioctl(struct tcb *const tcp, const unsigned int code, const size_t size = _IOC_SIZE(code) / sizeof(int); if (!size) { printaddr(arg); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } int buffer[size]; if (umove_or_printaddr(tcp, arg, &buffer)) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{code="); printxval(evdev_mtslots, buffer[0], "ABS_MT_???"); @@ -332,7 +332,7 @@ mtslots_ioctl(struct tcb *const tcp, const unsigned int code, tprints("]}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } # endif /* EVIOCGMTSLOTS */ @@ -342,7 +342,7 @@ repeat_ioctl(struct tcb *const tcp, const kernel_ulong_t arg) { tprints(", "); printpair_int(tcp, arg, "%u"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } # endif /* EVIOCGREP || EVIOCSREP */ @@ -386,14 +386,14 @@ bit_ioctl(struct tcb *const tcp, const unsigned int ev_nr, case EV_PWR: tprints(", "); printnum_int(tcp, arg, "%d"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; case EV_FF_STATUS: return decode_bitset(tcp, arg, evdev_ff_status, FF_STATUS_MAX, "FF_STATUS_???"); default: tprints(", "); printaddr(arg); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } } @@ -406,11 +406,11 @@ evdev_read_ioctl(struct tcb *const tcp, const unsigned int code, case EVIOCGVERSION: tprints(", "); printnum_int(tcp, arg, "%#x"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; case EVIOCGEFFECTS: tprints(", "); printnum_int(tcp, arg, "%u"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; case EVIOCGID: return getid_ioctl(tcp, arg); # ifdef EVIOCGREP @@ -439,7 +439,7 @@ evdev_read_ioctl(struct tcb *const tcp, const unsigned int code, printaddr(arg); else printstrn(tcp, arg, tcp->u_rval); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; # ifdef EVIOCGPROP case _IOC_NR(EVIOCGPROP(0)): return decode_bitset(tcp, arg, evdev_prop, @@ -492,18 +492,18 @@ evdev_write_ioctl(struct tcb *const tcp, const unsigned int code, return ff_effect_ioctl(tcp, arg); case EVIOCRMFF: tprintf(", %d", (int) arg); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; case EVIOCGRAB: # ifdef EVIOCREVOKE case EVIOCREVOKE: # endif tprintf(", %" PRI_klu, arg); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; # ifdef EVIOCSCLOCKID case EVIOCSCLOCKID: tprints(", "); printnum_int(tcp, arg, "%u"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; # endif } diff --git a/file_ioctl.c b/file_ioctl.c index 2391431e..c27ae5ea 100644 --- a/file_ioctl.c +++ b/file_ioctl.c @@ -245,5 +245,5 @@ file_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; }; - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/fs_x_ioctl.c b/fs_x_ioctl.c index 0c8f60e1..c22498e9 100644 --- a/fs_x_ioctl.c +++ b/fs_x_ioctl.c @@ -62,5 +62,5 @@ fs_x_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/hdio.c b/hdio.c index a987ad01..2e4e1c8a 100644 --- a/hdio.c +++ b/hdio.c @@ -60,5 +60,5 @@ MPERS_PRINTER_DECL(int, hdio_ioctl, struct tcb *const tcp, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/ioctl.c b/ioctl.c index 280bc24d..b61a5be5 100644 --- a/ioctl.c +++ b/ioctl.c @@ -229,29 +229,27 @@ ioctl_decode_command_number(struct tcb *tcp) * * @return There are two flags of the return value important for the purposes of * processing by SYS_FUNC(ioctl): - * - RVAL_IOCTL_PARSED - indicates that ioctl decoder code has printed - * arg parameter. - * - RVAL_DECODED - indicates that decoding is done. + * - RVAL_IOCTL_DECODED: indicates that ioctl decoder code + * has printed arg parameter; + * - RVAL_DECODED: indicates that decoding is done. * As a result, the following behaviour is expected: * - on entering: - * - 0 - decoding should be continued on exiting; - * - RVAL_DECODED - decoding on exiting is not needed and generic - * handler should print arg value; - * - RVAL_IOCTL_PARSED | RVAL_DECODED - decoding on exiting is not - * needed and decoder - * has printed arg value. + * - 0: decoding should be continued on exiting; + * - RVAL_IOCTL_DECODED: decoding on exiting is not needed + * and decoder has printed arg value; + * - RVAL_DECODED: decoding on exiting is not needed + * and generic handler should print arg value. * - on exiting: - * - 0 - generic handler should print arg value. - * - RVAL_IOCTL_PARSED - decoder has printed arg value. + * - 0: generic handler should print arg value; + * - RVAL_IOCTL_DECODED: decoder has printed arg value. * - * Note that it makes no sense to return just RVAL_IOCTL_PARSED - * on entering, or RVAL_IOCTL_PARSED | RVAL_DECODED on exiting, but, - * of course, it is not prohibited (for example, it may be useful + * Note that it makes no sense to return just RVAL_DECODED on exiting, + * but, of course, it is not prohibited (for example, it may be useful * in cases where the return path is common on entering and on exiting * the syscall). * - * SYS_FUNC(ioctl) clears RVAL_IOCTL_PARSED flag and passes all other - * bits of ioctl_decode return value unchanged. + * SYS_FUNC(ioctl) converts RVAL_IOCTL_DECODED flag to RVAL_DECODED, + * and passes all other bits of ioctl_decode return value unchanged. */ static int ioctl_decode(struct tcb *tcp) @@ -348,10 +346,12 @@ SYS_FUNC(ioctl) ret = ioctl_decode(tcp) | RVAL_DECODED; } - if ((ret & RVAL_DECODED) && !(ret & RVAL_IOCTL_PARSED)) + if (ret & RVAL_IOCTL_DECODED) { + ret &= ~RVAL_IOCTL_DECODED; + ret |= RVAL_DECODED; + } else if (ret & RVAL_DECODED) { tprintf(", %#" PRI_klx, tcp->u_arg[2]); - - ret &= ~RVAL_IOCTL_PARSED; + } return ret; } diff --git a/loop.c b/loop.c index 9ed8a3e8..4811dc00 100644 --- a/loop.c +++ b/loop.c @@ -196,5 +196,5 @@ MPERS_PRINTER_DECL(int, loop_ioctl, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/mtd.c b/mtd.c index cd6584bf..8e5fe46c 100644 --- a/mtd.c +++ b/mtd.c @@ -360,5 +360,5 @@ MPERS_PRINTER_DECL(int, mtd_ioctl, struct tcb *const tcp, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/nsfs.c b/nsfs.c index 2b39eaf8..493dcd57 100644 --- a/nsfs.c +++ b/nsfs.c @@ -37,7 +37,7 @@ nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg) switch (code) { case NS_GET_USERNS: case NS_GET_PARENT: - return RVAL_IOCTL_PARSED | RVAL_FD | RVAL_DECODED; + return RVAL_IOCTL_DECODED | RVAL_FD; case NS_GET_NSTYPE: if (entering(tcp)) return 0; @@ -46,10 +46,10 @@ nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg) outstr = xlookup(setns_types, tcp->u_rval); if (outstr) { tcp->auxstr = outstr; - return RVAL_IOCTL_PARSED | RVAL_STR; + return RVAL_IOCTL_DECODED | RVAL_STR; } } - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; case NS_GET_OWNER_UID: if (entering(tcp)) return 0; @@ -58,7 +58,7 @@ nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg) printuid("[", uid); tprints("]"); } - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; default: return RVAL_DECODED; } diff --git a/print_sg_req_info.c b/print_sg_req_info.c index c3bdba93..deb8d661 100644 --- a/print_sg_req_info.c +++ b/print_sg_req_info.c @@ -68,7 +68,7 @@ MPERS_PRINTER_DECL(int, decode_sg_req_info, tprintf(", duration=%u}", info.duration); } - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #endif /* HAVE_SCSI_SG_H */ diff --git a/ptp.c b/ptp.c index 97853d89..fce6e0e8 100644 --- a/ptp.c +++ b/ptp.c @@ -136,5 +136,5 @@ ptp_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/rtc.c b/rtc.c index 38c1e424..37d35391 100644 --- a/rtc.c +++ b/rtc.c @@ -150,5 +150,5 @@ MPERS_PRINTER_DECL(int, rtc_ioctl, struct tcb *const tcp, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/scsi.c b/scsi.c index 343bd00f..e4a776ea 100644 --- a/scsi.c +++ b/scsi.c @@ -46,7 +46,7 @@ decode_sg_io(struct tcb *const tcp, const uint32_t iid, return decode_sg_io_v4(tcp, arg); default: tprintf("[%u]", iid); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } } @@ -78,7 +78,7 @@ decode_sg_scsi_id(struct tcb *const tcp, const kernel_ulong_t arg) id.h_cmd_per_lun, id.d_queue_depth); } - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #endif /* HAVE_SCSI_SG_H */ @@ -179,5 +179,5 @@ scsi_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/sg_io_v3.c b/sg_io_v3.c index f4d4be51..88f9dfc8 100644 --- a/sg_io_v3.c +++ b/sg_io_v3.c @@ -78,7 +78,7 @@ decode_request(struct tcb *const tcp, const kernel_ulong_t arg) if (umoven_or_printaddr(tcp, arg + skip_iid, sizeof(sg_io) - skip_iid, &sg_io.dxfer_direction)) { tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } PRINT_FIELD_XVAL("", sg_io, dxfer_direction, sg_io_dxfer_direction, @@ -117,12 +117,12 @@ decode_response(struct tcb *const tcp, const kernel_ulong_t arg) if (entering_sg_io->dxfer_direction == SG_DXFER_FROM_DEV) PRINT_FIELD_PTR(", ", *entering_sg_io, dxferp); PRINT_FIELD_PTR(", ", *entering_sg_io, sbp); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } if (sg_io.interface_id != entering_sg_io->interface_id) { PRINT_FIELD_U(" => ", sg_io, interface_id); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } if (sg_io.dxfer_direction == SG_DXFER_FROM_DEV || @@ -155,7 +155,7 @@ decode_response(struct tcb *const tcp, const kernel_ulong_t arg) PRINT_FIELD_U(", ", sg_io, duration); PRINT_FIELD_FLAGS(", ", sg_io, info, sg_io_info, "SG_INFO_???"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #else /* !HAVE_SCSI_SG_H */ @@ -164,7 +164,7 @@ static int decode_request(struct tcb *const tcp, const kernel_ulong_t arg) { tprints("{interface_id='S', ...}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int diff --git a/sg_io_v4.c b/sg_io_v4.c index f3e88f09..2a8380fa 100644 --- a/sg_io_v4.c +++ b/sg_io_v4.c @@ -64,7 +64,7 @@ decode_request(struct tcb *const tcp, const kernel_ulong_t arg) if (umoven_or_printaddr(tcp, arg + skip_iid, sizeof(sg_io) - skip_iid, &sg_io.protocol)) { tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } PRINT_FIELD_XVAL("", sg_io, protocol, bsg_protocol, "BSG_PROTOCOL_???"); @@ -111,12 +111,12 @@ decode_response(struct tcb *const tcp, const kernel_ulong_t arg) /* print i/o fields fetched on entering syscall */ PRINT_FIELD_X(", ", *entering_sg_io, response); PRINT_FIELD_X(", ", *entering_sg_io, din_xferp); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } if (sg_io.guard != entering_sg_io->guard) { PRINT_FIELD_U(" => ", sg_io, guard); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } PRINT_FIELD_U(", ", sg_io, response_len); @@ -138,7 +138,7 @@ decode_response(struct tcb *const tcp, const kernel_ulong_t arg) PRINT_FIELD_D(", ", sg_io, dout_resid); PRINT_FIELD_X(", ", sg_io, generated_tag); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #else /* !HAVE_LINUX_BSG_H */ @@ -147,7 +147,7 @@ static int decode_request(struct tcb *const tcp, const kernel_ulong_t arg) { tprints("{guard='Q', ...}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int diff --git a/sock.c b/sock.c index 840b76ea..cd13de48 100644 --- a/sock.c +++ b/sock.c @@ -198,7 +198,7 @@ decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr) tprints("}"); } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } if (entering(tcp)) { @@ -237,7 +237,7 @@ decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr) tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } MPERS_PRINTER_DECL(int, sock_ioctl, @@ -371,5 +371,5 @@ MPERS_PRINTER_DECL(int, sock_ioctl, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/term.c b/term.c index a52298c9..9368e5fd 100644 --- a/term.c +++ b/term.c @@ -286,5 +286,5 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/ubi.c b/ubi.c index ab4f5ea0..1c12a23e 100644 --- a/ubi.c +++ b/ubi.c @@ -196,5 +196,5 @@ ubi_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } diff --git a/userfaultfd.c b/userfaultfd.c index 94ed20a2..2fa33c77 100644 --- a/userfaultfd.c +++ b/userfaultfd.c @@ -114,7 +114,7 @@ uffdio_ioctl(struct tcb *const tcp, const unsigned int code, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &uc)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; PRINT_FIELD_X("{", uc, dst); PRINT_FIELD_X(", ", uc, src); PRINT_FIELD_X(", ", uc, len); @@ -138,7 +138,7 @@ uffdio_ioctl(struct tcb *const tcp, const unsigned int code, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &ur)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; PRINT_FIELD_UFFDIO_RANGE("{", ur, range); PRINT_FIELD_FLAGS(", ", ur, mode, uffd_register_mode_flags, @@ -176,7 +176,7 @@ uffdio_ioctl(struct tcb *const tcp, const unsigned int code, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &uz)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; PRINT_FIELD_UFFDIO_RANGE("{", uz, range); PRINT_FIELD_FLAGS(", ", uz, mode, uffd_zeropage_flags, "UFFDIO_ZEROPAGE_???"); @@ -196,6 +196,6 @@ uffdio_ioctl(struct tcb *const tcp, const unsigned int code, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #endif /* HAVE_LINUX_USERFAULTFD_H */ diff --git a/v4l2.c b/v4l2.c index 8b839b57..097b13ac 100644 --- a/v4l2.c +++ b/v4l2.c @@ -146,7 +146,7 @@ print_v4l2_capability(struct tcb *const tcp, const kernel_ulong_t arg) return 0; tprints(", "); if (umove_or_printaddr(tcp, arg, &caps)) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; PRINT_FIELD_CSTRING("{", caps, driver); PRINT_FIELD_CSTRING(", ", caps, card); PRINT_FIELD_CSTRING(", ", caps, bus_info); @@ -162,7 +162,7 @@ print_v4l2_capability(struct tcb *const tcp, const kernel_ulong_t arg) "V4L2_CAP_???"); #endif tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_buf_types.h" @@ -176,7 +176,7 @@ print_v4l2_fmtdesc(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &f)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{index=%u, type=", f.index); printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???"); return 0; @@ -191,7 +191,7 @@ print_v4l2_fmtdesc(struct tcb *const tcp, const kernel_ulong_t arg) print_pixelformat(f.pixelformat); } tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_fields.h" @@ -354,14 +354,14 @@ print_v4l2_format(struct tcb *const tcp, const kernel_ulong_t arg, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &f)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{type="); printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???"); if (is_get) return 0; if (!print_v4l2_format_fmt(tcp, ", ", &f)) { tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } return 0; @@ -372,7 +372,7 @@ print_v4l2_format(struct tcb *const tcp, const kernel_ulong_t arg, tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_memories.h" @@ -386,7 +386,7 @@ print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg) tprints(", "); if (umove_or_printaddr(tcp, arg, &reqbufs)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{type="); printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???"); @@ -408,7 +408,7 @@ print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_buf_flags.h" @@ -422,7 +422,7 @@ print_v4l2_buffer(struct tcb *const tcp, const unsigned int code, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &b)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{type="); printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???"); if (code != VIDIOC_DQBUF) @@ -456,7 +456,7 @@ print_v4l2_buffer(struct tcb *const tcp, const unsigned int code, tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int @@ -472,7 +472,7 @@ print_v4l2_framebuffer(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int @@ -486,7 +486,7 @@ print_v4l2_buf_type(struct tcb *const tcp, const kernel_ulong_t arg) printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???"); tprints("]"); } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_streaming_capabilities.h" @@ -501,7 +501,7 @@ print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &s)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{type="); printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???"); switch (s.type) { @@ -513,12 +513,12 @@ print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg, break; default: tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } } else { if (syserror(tcp) || umove(tcp, arg, &s) < 0) { tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } tprints(is_get ? ", " : " => "); } @@ -552,9 +552,12 @@ print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg, s.parm.output.extendedmode, s.parm.output.writebuffers); } - if (exiting(tcp)) + if (entering(tcp)) { + return 0; + } else { tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; + } } static int @@ -565,7 +568,7 @@ print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &s)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{index=%u", s.index); return 0; @@ -580,7 +583,7 @@ print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_input_types.h" @@ -593,7 +596,7 @@ print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &i)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{index=%u", i.index); return 0; @@ -607,7 +610,7 @@ print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_control_ids.h" @@ -621,7 +624,7 @@ print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &c)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{id="); printxval(v4l2_control_ids, c.id, "V4L2_CID_???"); if (!is_get) @@ -636,7 +639,7 @@ print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg, tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #include "xlat/v4l2_tuner_types.h" @@ -652,7 +655,7 @@ print_v4l2_tuner(struct tcb *const tcp, const kernel_ulong_t arg, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &c)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{index=%u", c.index); if (is_get) return 0; @@ -660,7 +663,7 @@ print_v4l2_tuner(struct tcb *const tcp, const kernel_ulong_t arg, } else { if (syserror(tcp) || umove(tcp, arg, &c) < 0) { tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } tprints(is_get ? ", " : " => "); } @@ -680,9 +683,12 @@ print_v4l2_tuner(struct tcb *const tcp, const kernel_ulong_t arg, "V4L2_TUNER_MODE_???"); tprintf(", signal=%d, afc=%d", c.signal, c.afc); - if (exiting(tcp)) + if (entering(tcp)) { + return 0; + } else { tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; + } } #include "xlat/v4l2_control_types.h" @@ -696,12 +702,12 @@ print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &c)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{id="); } else { if (syserror(tcp) || umove(tcp, arg, &c) < 0) { tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } if (get_tcb_priv_ulong(tcp)) tprints(" => "); @@ -729,7 +735,7 @@ print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg) printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???"); tprints("}"); } - return RVAL_IOCTL_PARSED; + return entering(tcp) ? 0 : RVAL_IOCTL_DECODED; } static int @@ -740,7 +746,7 @@ print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &c)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{type="); printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???"); @@ -758,7 +764,7 @@ print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } static int @@ -770,7 +776,7 @@ print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &c)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{type="); printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???"); if (is_get) @@ -783,7 +789,7 @@ print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg, tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #ifdef VIDIOC_S_EXT_CTRLS @@ -818,14 +824,14 @@ print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg, if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &c)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprints("{ctrl_class="); printxval(v4l2_control_classes, c.ctrl_class, "V4L2_CTRL_CLASS_???"); tprintf(", count=%u", c.count); if (!c.count) { tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } if (is_get) return 0; @@ -833,7 +839,7 @@ print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg, } else { if (umove(tcp, arg, &c) < 0) { tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } tprints(is_get ? ", " : " => "); } @@ -850,7 +856,7 @@ print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg, if (exiting(tcp) || fail) { tprints("}"); - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } /* entering */ @@ -869,7 +875,7 @@ print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &s)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{index=%u, pixel_format=", s.index); print_pixelformat(s.pixel_format); return 0; @@ -894,7 +900,7 @@ print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg) } } tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #endif /* VIDIOC_ENUM_FRAMESIZES */ @@ -909,7 +915,7 @@ print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &f)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{index=%u, pixel_format=", f.index); print_pixelformat(f.pixel_format); tprintf(", width=%u, height=%u", f.width, f.height); @@ -938,7 +944,7 @@ print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg) tprints("}"); - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } #endif /* VIDIOC_ENUM_FRAMEINTERVALS */ @@ -954,7 +960,7 @@ print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg) if (entering(tcp)) { tprints(", "); if (umove_or_printaddr(tcp, arg, &b)) - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; tprintf("{count=%u, memory=", b.count); printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???"); tprints(", format={type="); @@ -967,12 +973,12 @@ print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg) } if (syserror(tcp) || umove(tcp, arg, &b)) - return RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; sprintf(outstr, fmt, b.index, b.count); tcp->auxstr = outstr; - return RVAL_IOCTL_PARSED | RVAL_STR; + return RVAL_IOCTL_DECODED | RVAL_STR; } #endif /* VIDIOC_CREATE_BUFS */ @@ -1086,5 +1092,5 @@ MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp, return RVAL_DECODED; } - return RVAL_DECODED | RVAL_IOCTL_PARSED; + return RVAL_IOCTL_DECODED; } -- 2.40.0