Fix: LTTng-modules ABI ioctl wrong direction
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 20 Apr 2021 15:05:19 +0000 (11:05 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Apr 2021 20:05:59 +0000 (16:05 -0400)
commit8c71721f7a868b575b05e24bc3a3dcc967e6d5d6
tree3092010d0cbddee5e7ba45c3451b21542e473998
parent8a44545778a66f5c473b348ff0231145d59e1d21
Fix: LTTng-modules ABI ioctl wrong direction

lttng-modules defines ioctl numbers (include/lttng/abi.h) using the
_IO*() macros. These macros are partly used to specify what type of
parameters that the ioctl will be expecting. It also specifies the
direction of the data flow.

    1. sending data from userspace to the kernel,
    2. sending data from the kernel to userspace,
    3. both.

According to the kernel's
Documentation/userspace-api/ioctl/ioctl-number.rst file here is the
meaning of the various macros:

 ====== == ============================================
 _IO    an ioctl with no parameters
 _IOW   an ioctl with write parameters (copy_from_user)
 _IOR   an ioctl with read parameters  (copy_to_user)
 _IOWR  an ioctl with both write and read parameters.
 ====== == ============================================

Some of our use of these macros are wrong. In some cases, we use _IOW()
when we should be using _IOR():

Here is a list of the ioctl numbers that should be _IOW() as they are
sending data to the kernel:

 #define LTTNG_KERNEL_SESSION_TRACK_PID      IOR(0xF6, 0x58, int32_t)
 #define LTTNG_KERNEL_SESSION_UNTRACK_PID    _IOR(0xF6, 0x59, int32_t)
 #define LTTNG_KERNEL_SESSION_SET_NAME       _IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
 #define LTTNG_KERNEL_SESSION_SET_CREATION_TIME   _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS  _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args)
 #define LTTNG_KERNEL_SESSION_TRACK_ID          _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args)
 #define LTTNG_KERNEL_SESSION_UNTRACK_ID        _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args)

Fix this by changing the direction of the macros, but introduce "_OLD"
macros for backward compatibility.

User-space should gradually start interacting with the correct ioctl
direction. However, in order to preserve compatibility between newer
user-space tools and older lttng-modules, user-space should fall-back on
the "_OLD" ioctl directions if the new directions are not implemented by
an older lttng-modules.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I70d1963464597e0e3b028a67739d4a13b96c1ea5
include/lttng/abi.h
src/lttng-abi.c
This page took 0.026547 seconds and 4 git commands to generate.