All of lore.kernel.org
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] lib: Add tst_sysfs_assert
Date: Tue, 25 Aug 2026 13:19:38 +0000	[thread overview]
Message-ID: <20260825131939.5201-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260825113625.1624134-2-chrubis@suse.cz>

Hi Cyril,

On Tue, 25 Aug 2026, Cyril Hrubis wrote:
> lib: Add tst_sysfs_assert

This is a review of the 31-patch sysfs series. Comments are grouped per
patch; only patches with findings are quoted below.

--- [PATCH 1/31] lib: Add tst_sysfs_assert ---

> Adds helpers for a sysfs testcases.

The body only restates the subject. Could it say why the helper API is
needed (which upcoming tests use it, what problem it solves)? A ~1500 line
new public API is not self-explanatory from the subject alone.

> 	/* First pass: only to find the highest id so we can size the bitmap. */
> 	if (parse_list(file, lineno, path, NULL, NULL, &max_id))
> 		return NULL;
>
> 	bytes = max_id < 0 ? 1 : max_id / 8 + 1;
> 	map = SAFE_MALLOC(bytes);
> 	memset(map, 0, bytes);
>
> 	/* Second pass: fill the bitmap. */
> 	if (parse_list(file, lineno, path, map, NULL, NULL)) {

read_list_map() sizes the bitmap from a first parse and then fills it from a
second, independent parse of the same file. parse_list() writes without a
bounds check:

> 		if (map)
> 			map[i / 8] |= 1 << (i % 8);

The documented sources include mutable lists (cpu online/offline, node
online). If the list grows across an 8-id boundary between the two reads,
e.g. a CPU whose id exceeds the first pass's max is onlined by concurrent
hotplug, the second pass parses a higher id than "bytes" was sized for and
map[i / 8] writes past the allocation. Would it be safer to size the bitmap
from a fixed upper bound (kernel_max / nr possible), or to cap parse_list()
writes against the allocation size?

> unsigned long tst_sysfs_read_lx(const char *file, const int lineno,

> /**
>  * TST_SYSFS_READ_LX() - Reads a hexadecimal unsigned long from a file.
>  *
>  * Reads a long value from the file at the path built from fmt and returns it.

The description body says "Reads a long value" while the summary and the
implementation read a hexadecimal unsigned long (looks copy-pasted from
TST_SYSFS_READ_LI).

--- [PATCH 3/31] testcases: sysfs: Add sys_kernel01 ---

> +top_srcdir		?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk
> +include $(top_srcdir)/include/mk/generic_trunk_target.mk

This is a leaf test directory (it holds sys_kernel01.c and no
subdirectories) but includes the trunk target. generic_trunk_target.inc
errors out when SUBDIRS is empty:

    ifeq ($(strip $(SUBDIRS)),)
        $(error SUBDIRS empty -- did you want generic_leaf_target instead?)

so building this directory aborts, and sys_kernel01 is never built even
though runtest/sysfs and .gitignore reference it. Should it use
generic_leaf_target.mk like the sibling power/Makefile?

Note that patch 27 later adds kernel/mm/ under this directory, which makes
SUBDIRS non-empty and hides the hard error, but the trunk target still does
not compile sys_kernel01.c (it only recurses into mm/), so at the end of the
series sys_kernel01 is silently never built.

--- [PATCH 8/31] testcases: sysfs: Add sys_cpu_vulnerabilities01 ---

> +static const char *const known_prefixes[] = {
> +	"Not affected",
> +	"Vulnerable",
> +	"Mitigation:",
> +	"Unknown",
> +	"Processor vulnerable",
> +};

/sys/devices/system/cpu/vulnerabilities/itlb_multihit is emitted by
itlb_multihit_show_state() in arch/x86/kernel/cpu/bugs.c as one of:

    "KVM: Mitigation: VMX unsupported"
    "KVM: Mitigation: VMX disabled"
    "KVM: Mitigation: Split huge pages"
    "KVM: Vulnerable"

These start with "KVM: ", which matches none of the known prefixes, so
check_vuln() reports TFAIL on the common x86 Intel host that exposes
itlb_multihit. Should a "KVM:" prefix be added (or the "Mitigation:"/
"Vulnerable" match allowed after an optional "KVM: ")?

--- [PATCH 12/31] testcases: sysfs: Add sys_ata01 ---

> +static const char *const class_allowed[] = {
> +	"ata", "atapi", "pmp", "semb", "unknown", NULL
> +};

/sys/class/ata_device/<dev>/class is produced by get_ata_class_names() over
ata_class_names[] in drivers/ata/libata-transport.c, whose table also
contains:

    { ATA_DEV_ZAC,   "zac" },
    { ATA_DEV_NONE,  "none" }

A ZAC (host-managed SMR) ATA device reports class "zac", which is not in
class_allowed, so TST_SYSFS_ASSERT_ONEOF reports TFAIL for a valid value.
Should "zac" (and "none") be added?

--- [PATCH 23/31] testcases: sysfs: Add sys_net04 ---

> +	if (tun_fd >= 0)
> +		SAFE_CLOSE(tun_fd);
> +
> +	if (tap_fd >= 0)
> +		SAFE_CLOSE(tap_fd);

Both descriptors are initialized to -1; the convention is to test them with
fd != -1 rather than fd >= 0.

--- [PATCH 30/31] testcases: sysfs: Add sys_swap01 ---

> testcases: sysfs: Add sys_swap01

The test added is sys_mm_swap01 (sys_mm_swap01.c, runtest entry
"sys_mm_swap01 sys_mm_swap01", .gitignore /sys_mm_swap01). The subject names
sys_swap01, which does not match the actual test.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-08-25 13:20 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 11:35 [LTP] [PATCH v3 00/31] Add sysfs sanity tests Cyril Hrubis
2026-08-25 11:35 ` [LTP] [PATCH v3 01/31] lib: Add tst_sysfs_assert Cyril Hrubis
2026-08-25 13:19   ` linuxtestproject.agent [this message]
2026-08-25 11:35 ` [LTP] [PATCH v3 02/31] testcases: sysfs: Add sys_power01 Cyril Hrubis
2026-08-25 11:35 ` [LTP] [PATCH v3 03/31] testcases: sysfs: Add sys_kernel01 Cyril Hrubis
2026-08-25 11:35 ` [LTP] [PATCH v3 04/31] testcases: sysfs: Add sys_clocksource01 Cyril Hrubis
2026-08-25 11:35 ` [LTP] [PATCH v3 05/31] testcases: sysfs: Add sys_node01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 06/31] testcases: sysfs: Add sys_cpu_topology01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 07/31] testcases: sysfs: Add sys_cpu_topology02 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 08/31] testcases: sysfs: Add sys_cpu_vulnerabilities01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 09/31] testcases: sysfs: Add sys_cpu_smt01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 10/31] testcases: sysfs: Add sys_cpu_cache01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 11/31] testcases: sysfs: Add sys_clockevents01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 12/31] testcases: sysfs: Add sys_ata01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 13/31] testcases: sysfs: Add sys_bdi01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 14/31] testcases: sysfs: sys_hwmon01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 15/31] testcases: sysfs: sys_leds01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 16/31] testcases: sysfs: Add sys_wakeup01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 17/31] testcases: sysfs: Add sys_rtc01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 18/31] testcases: sysfs: Add sys_thermal01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 19/31] tst_netdevice: Add two more helper macros Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 20/31] testcases: sysfs: Add sys_net01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 21/31] testcases: sysfs: Add sys_net02 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 22/31] testcases: sysfs: Add sys_net03 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 23/31] testcases: sysfs: Add sys_net04 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 24/31] testcases: sysfs: Add sys_block_loop01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 25/31] testcases: sysfs: Add sys_block_queue01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 26/31] testcases: sysfs: Add sys_block_size01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 27/31] testcases: sysfs: Add sys_hugepages01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 28/31] testcases: sysfs: Add sys_hugepages02 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 29/31] testcases: sysfs: Add sys_ksm01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 30/31] testcases: sysfs: Add sys_swap01 Cyril Hrubis
2026-08-25 11:36 ` [LTP] [PATCH v3 31/31] testcases: sysfs: Add sys_thp01 Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2026-08-27 11:21 [LTP] [PATCH v4 02/31] testcases: sysfs: Add sys_power01 Cyril Hrubis
2026-08-27 14:04 ` [LTP] lib: Add tst_sysfs_assert linuxtestproject.agent
2026-08-19 16:16 [LTP] [PATCH v2 03/31] testcases: sysfs: Add sys_kernel01 Cyril Hrubis
2026-08-20  7:58 ` [LTP] lib: Add tst_sysfs_assert linuxtestproject.agent
2026-08-18 14:12 [LTP] [PATCH v1 03/31] testcases: sysfs: Add sys_kernel01 Cyril Hrubis
2026-08-18 14:54 ` [LTP] lib: Add tst_sysfs_assert linuxtestproject.agent
2026-08-19 16:13   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260825131939.5201-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.