[PATCH v2 0/6] arbitrate overwrapped IOCTL command assignments

Masatake YAMATO yamato at redhat.com
Fri Mar 11 18:02:03 UTC 2022


arbitrate overwrapped IOCTL command assignments

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

Changes in v2:

  Renamed strcut fd_info to struct finfo because the name "fd_info" is
  wrongly associated with data structure for loading data from
  /proc/$pid/fdinfo.

  Reflected ldv's review comments.
  
Masatake YAMATO (6):
  Split printdev() into functions for printing and getting information
    about fd
  Allow to pass pre-filled finfo data to printdev() function from upper
    layers
  Collect finfo just before decoding ioctl command
  Use finfo structure to arbitrate overwrapped IOCTL command assignments
    between TTY and SND
  Fill finfo structure only when a decoder requests
  tests: add a test case for the abitrator of ioctl command overwrapping

 src/defs.h                  | 33 ++++++++++++++++-
 src/ioctl.c                 | 29 +++++++++++++--
 src/term.c                  | 64 +++++++++++++++++++++++++++++++++
 src/util.c                  | 61 ++++++++++++++++++++++---------
 tests/.gitignore            |  1 +
 tests/gen_tests.in          |  1 +
 tests/ioctl_overwrap.c      | 71 +++++++++++++++++++++++++++++++++++++
 tests/pure_executables.list |  1 +
 8 files changed, 241 insertions(+), 20 deletions(-)
 create mode 100644 tests/ioctl_overwrap.c

-- 
2.35.1



More information about the Strace-devel mailing list