[PATCH 0/6] arbitrate overwrapped IOCTL command assignments

Masatake YAMATO yamato at redhat.com
Thu Mar 10 12:01:00 UTC 2022


IOCTL command assignments are overwrapped.
We can observe the overwrapping when running vi under strace:

  ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0
----------------------------^^

We can remove the ambiguity if strace knows about the object behind a
given file descriptor. In the above example, whether the fd (0) is
associated with a sound device or a terminal is the hint for removing
the ambiguity.

We don't have to develop new code for getting the hint from scratch;
the code implementing -y option gathers information about fd already.

  ioctl(0</dev/pts/26<char 136:26>>, TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0
----------------------^^^^^^^^^^^

Currently, the information gathered with -y option is used only for
printing.  This patch-set utilizes the information for improving the
quality of decoding.

With the patch-set, strace reports the ioctl as following:

  ioctl(0, TCSETS, {B38400 opost -isig -icanon -echo ...}) = 0

                      
Masatake YAMATO (6):
  Add functions for disabling tprint* functions temporary
  Extend printfd() to collect extra information about fd
  Use fd_info structure to arbitrate overwrapped IOCTL command
    assignments between PTS and SND
  Fill fd_info structure only when a decoder requests
  tests: fix a typo in tests.h
  tests: add a test case for the abitrator of ioctl command overwrapping

 src/defs.h                  | 28 +++++++++++++++--
 src/ioctl.c                 | 28 +++++++++++++++--
 src/strace.c                | 14 +++++++++
 src/term.c                  | 41 ++++++++++++++++++++++++
 src/util.c                  | 39 ++++++++++++++++++++---
 tests/.gitignore            |  1 +
 tests/gen_tests.in          |  1 +
 tests/ioctl_overwrap.c      | 63 +++++++++++++++++++++++++++++++++++++
 tests/pure_executables.list |  1 +
 tests/tests.h               |  2 +-
 10 files changed, 207 insertions(+), 11 deletions(-)
 create mode 100644 tests/ioctl_overwrap.c

-- 
2.35.1



More information about the Strace-devel mailing list