lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260115163650.118910-1-wander@redhat.com>
Date: Thu, 15 Jan 2026 13:31:43 -0300
From: Wander Lairson Costa <wander@...hat.com>
To: Steven Rostedt <rostedt@...dmis.org>,
	Tomas Glozar <tglozar@...hat.com>,
	Wander Lairson Costa <wander@...hat.com>,
	Crystal Wood <crwood@...hat.com>,
	Ivan Pravdin <ipravdin.official@...il.com>,
	Costa Shulyupin <costa.shul@...hat.com>,
	John Kacur <jkacur@...hat.com>,
	Tiezhu Yang <yangtiezhu@...ngson.cn>,
	Daniel Wagner <dwagner@...e.de>,
	Daniel Bristot de Oliveira <bristot@...nel.org>,
	linux-trace-kernel@...r.kernel.org (open list:Real-time Linux Analysis (RTLA) tools),
	linux-kernel@...r.kernel.org (open list:Real-time Linux Analysis (RTLA) tools),
	bpf@...r.kernel.org (open list:BPF [MISC]:Keyword:(?:\b|_)bpf(?:\b|_))
Subject: [PATCH v3 00/18] rtla: Robustness and code quality improvements

This series addresses multiple issues in the rtla codebase related to
error handling, string manipulation safety, and code maintainability.
The changes improve the tool's reliability and bring the code more in
line with kernel coding practices.

The series can be broadly divided into three categories:

Bug fixes address several correctness issues: a resource leak where
opendir() was not paired with closedir() on success paths, I/O loops
that failed to handle EINTR and partial writes correctly, a missing
bounds check when indexing the softirq_name array with kernel-provided
data, improper handling of pthread_create() failures, and a loop
condition that checked a pointer instead of the character it points to.

String handling improvements replace unsafe patterns throughout the
codebase. The strncpy() function is replaced with a new strscpy()
implementation that guarantees NUL-termination and provides truncation
detection. A str_has_prefix() helper replaces verbose strncmp/strlen
patterns for prefix matching. String comparisons are tightened to use
exact matching where appropriate, preventing silent acceptance of
malformed input like "100nsx" being parsed as "100ns".

Code quality improvements reduce duplication and improve readability.
A common_threshold_handler() consolidates repeated threshold action
logic. The extract_arg() macro simplifies key=value parsing. Magic
numbers are replaced with named constants (MAX_PATH, ARRAY_SIZE), and
redundant strlen() calls are cached in local variables.

All changes have been tested with the existing rtla test suite.

Changes:

v3:
- Address v2 feedback:
  - Rename common_restart() to common_threshold_handler() to better
    reflect its purpose (Tomas Glozar).
  - Implement a proper strscpy() for safer string handling instead of
    manual buffer sizing (Steven Rostedt).
  - Remove restart_result enum in favor of simpler, direct return
    values (Tomas Glozar).
- Add several new bug fixes, including a softirq vector bounds check,
  pthread_create() failure handling, robust I/O handling for
  EINTR/partial writes, and a resource leak fix.
- Introduce str_has_prefix() helper to replace verbose strncmp/strlen
  patterns.
- Tighten string parsing to enforce exact matching and reject invalid
  suffixes (e.g., "100nsx").
- Drop patches already merged via RTLA v6.20 pull request.

v2:
- exit on memory allocation failure
- remove redundant strlen() calls
- fix possible race on condition on stop_tracing variable access
- ensure null termination on read() calls
- fix checkpatch reports
- make extract_args() an inline function
- add the usage of common_restart() in more places

Wander Lairson Costa (18):
  rtla: Exit on memory allocation failures during initialization
  rtla: Use strdup() to simplify code
  rtla: Simplify argument parsing
  rtla: Introduce common_threshold_handler() helper
  rtla: Replace magic number with MAX_PATH
  rtla: Simplify code by caching string lengths
  rtla: Add strscpy() and replace strncpy() calls
  rtla/timerlat: Add bounds check for softirq vector
  rtla: Handle pthread_create() failure properly
  rtla: Add str_has_prefix() helper function
  rtla: Use str_has_prefix() for prefix checks
  rtla: Enforce exact match for time unit suffixes
  rtla: Use str_has_prefix() for option prefix check
  rtla/timerlat: Simplify RTLA_NO_BPF environment variable check
  rtla/trace: Fix write loop in trace_event_save_hist()
  rtla/trace: Fix I/O handling in save_trace_to_file()
  rtla/utils: Fix resource leak in set_comm_sched_attr()
  rtla/utils: Fix loop condition in PID validation

 tools/tracing/rtla/src/actions.c       | 103 ++++++++++++++----------
 tools/tracing/rtla/src/actions.h       |   8 +-
 tools/tracing/rtla/src/common.c        |  65 +++++++++++-----
 tools/tracing/rtla/src/common.h        |  18 +++++
 tools/tracing/rtla/src/osnoise.c       |  28 +++----
 tools/tracing/rtla/src/osnoise_hist.c  |  22 ++----
 tools/tracing/rtla/src/osnoise_top.c   |  22 ++----
 tools/tracing/rtla/src/timerlat.c      |   5 +-
 tools/tracing/rtla/src/timerlat_aa.c   |  10 +--
 tools/tracing/rtla/src/timerlat_hist.c |  41 ++++------
 tools/tracing/rtla/src/timerlat_top.c  |  54 ++++++-------
 tools/tracing/rtla/src/timerlat_u.c    |   4 +-
 tools/tracing/rtla/src/trace.c         | 101 +++++++++++++-----------
 tools/tracing/rtla/src/trace.h         |   4 +-
 tools/tracing/rtla/src/utils.c         | 104 ++++++++++++++++++++-----
 tools/tracing/rtla/src/utils.h         |  31 +++++++-
 16 files changed, 374 insertions(+), 246 deletions(-)

-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ