All of lore.kernel.org
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] lapi/keyctl.h: Add fallback definitions for extended ops
Date: Wed, 16 Sep 2026 18:19:33 +0000	[thread overview]
Message-ID: <20260916181933.4928-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260916140402.1797325-6-pvorel@suse.cz>

Hi Andrea,

On Wed, 16 Sep 2026 16:03:27 +0200, Andrea Cervesato <andrea.cervesato@suse.com> wrote:
> lapi/keyctl.h: Add fallback definitions for extended ops

--- [PATCH 1/36] ---

> +#ifndef HAVE_STRUCT_KEYCTL_DH_PARAMS
> +struct keyctl_dh_params {
> +	int32_t priv;
> +	int32_t prime;
> +	int32_t base;
> +};
> +#endif

HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV is probed in m4/ltp-keyutils.m4 for Leap
42.2 compatibility but is never handled here. When
HAVE_STRUCT_KEYCTL_DH_PARAMS is defined without
HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV, accessing dh_params->priv causes a build
failure. Add an alias:

#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
	!defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
# define priv private
#endif

--- [PATCH 2/36] ---

> +	if (rval == -1) {
> +		tst_brk_(file, lineno, TBROK | TERRNO,
> +			 "add_key(%s, '%s', %p, %ld, %d) failed",
> +			 type, desc, payload, size, keyring);
> +	} else if (rval < -1) {
> +		tst_brk_(file, lineno, TBROK | TERRNO,
> +			 "Invalid add_key(%s, '%s', %p, %ld, %d) return value %d",
> +			 type, desc, payload, size, keyring, rval);
> +	}

The size parameter has type size_t, but %ld is used in the format strings.
Use %zu instead.

> +#define SAFE_ADD_KEY(type, desc, payload, size, keyring) \
> +	safe_add_key(__FILE__, __LINE__, \
> +                            (type), (desc), (payload), (size), (keyring))

Use tabs instead of spaces for indentation.

--- [PATCH 4/36] ---

> +#define SAFE_NEW_RING(desc) \
> +	safe_add_key(__FILE__, __LINE__, "keyring", (desc), NULL, 0, KEY_SPEC_PROCESS_KEYRING)
> +
> +#define SAFE_NEW_USER_KEY(desc, payload, plen, ring) \
> +	safe_add_key(__FILE__, __LINE__, "user", (desc), (payload), (plen), (ring))

The SAFE_* prefix is reserved for LTP core library headers in include/.
Rename these macros without the SAFE_ prefix (e.g. NEW_RING and
NEW_USER_KEY) or move them to include/lapi/keyctl.h.

--- [PATCH 9/36] ---

> +	rc = SAFE_KEYCTL(KEYCTL_GET_SECURITY, key, (unsigned long)buf, sizeof(buf), 0);
> +
> +	if (buf[0] != '\0')
> +		tst_res(TFAIL, "empty label is not NUL terminated");

Checking buf[0] != '\0' unconditionally fails on systems where an LSM
(such as SELinux or Smack) is active and returns a non-empty security label.
Check buf[rc - 1] != '\0' instead to verify NUL-termination, or only check
buf[0] == '\0' when rc == 1.

--- [PATCH 14/36] ---

> +static void run(void)
> +{
> +	SAFE_KEYCTL(KEYCTL_LINK, key_a, ring_a, 0, 0);
> +	TST_EXP_PASS(keyctl(KEYCTL_MOVE, key_a, ring_a, ring_b, 0));
> +
> +	TST_EXP_EQ_LI(keyctl(KEYCTL_SEARCH, ring_b, "user", KEY_DESC), key_a);
> +}

When running multiple iterations (-i), key_excl is displaced from ring_b
in the first iteration and is never re-linked to ring_b. Subsequent
iterations therefore do not test displacement. Re-link key_excl to ring_b
in run() before moving key_a.

--- [PATCH 17/36] ---

> 		case 'i':
> -			iterations = SAFE_STRTOL(optarg, 0, INT_MAX);
> +			tst_test->iterations = SAFE_STRTOL(optarg, 0, UINT_MAX);

Passing UINT_MAX to SAFE_STRTOL() breaks on 32-bit architectures because
safe_strtol() takes signed long, where UINT_MAX (0xFFFFFFFF) converts to
-1L. This makes safe_strtol() reject any positive iteration count as out of
range 0 to -1. Use SAFE_STRTOUL(optarg, 0, UINT_MAX) or keep INT_MAX.

--- [PATCH 35/36] ---

> +	.ulimit = (const struct tst_ulimit_val []) {
> +		{RLIMIT_NOFILE, 524288},
> +		{}
> +	},

Setting .ulimit requires .needs_root = 1 when raising limits above the
current maximum. Without root privileges, safe_setrlimit() fails with
EPERM and aborts the test with TBROK. Either drop .ulimit or add
.needs_root = 1.

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-09-16 18:19 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 14:03 [LTP] [PATCH v3 00/36] Improve coverage for keyctl() syscall Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 01/36] lapi/keyctl.h: Add fallback definitions for extended ops Petr Vorel
2026-09-17  9:35   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 02/36] lapi/keyctl.h: Add SAFE_ADD_KEY() Petr Vorel
2026-09-17  9:38   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 03/36] tree: keyctl: Use SAFE_ADD_KEY() Petr Vorel
2026-09-17  9:43   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 04/36] keyctl10: Test KEYCTL_DESCRIBE format parsing Petr Vorel
2026-09-17  9:54   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 05/36] keyctl11: Test KEYCTL_DESCRIBE with exact buffer size Petr Vorel
2026-09-16 18:19   ` linuxtestproject.agent [this message]
2026-09-17 11:07   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 06/36] keyctl12: Test KEYCTL_DESCRIBE with too small buffer Petr Vorel
2026-09-17 11:14   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 07/36] keyctl13: Test KEYCTL_DESCRIBE size query Petr Vorel
2026-09-17 11:32   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 08/36] keyctl14: Negative tests for KEYCTL_DESCRIBE Petr Vorel
2026-09-18 15:42   ` Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 09/36] keyctl15: Test KEYCTL_GET_SECURITY label retrieval Petr Vorel
2026-09-17  8:54   ` Li Wang
2026-09-17 11:50     ` Cyril Hrubis
2026-09-18  5:01       ` Li Wang
2026-09-18  9:50         ` Cyril Hrubis
2026-09-18 10:59           ` Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 10/36] keyctl16: Test KEYCTL_GET_SECURITY truncated copy Petr Vorel
2026-09-17 14:01   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 11/36] keyctl17: Negative tests for KEYCTL_GET_SECURITY Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 12/36] keyctl18: Test basic KEYCTL_MOVE Petr Vorel
2026-09-17  9:51   ` Li Wang
2026-09-17 14:37   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 13/36] keyctl19: Test KEYCTL_MOVE with same source and destination Petr Vorel
2026-09-17  9:37   ` Li Wang
2026-09-16 14:03 ` [LTP] [PATCH v3 14/36] keyctl20: Test KEYCTL_MOVE displacement Petr Vorel
2026-09-17  9:38   ` Li Wang
2026-09-16 14:03 ` [LTP] [PATCH v3 15/36] keyctl21: Negative and boundary tests for KEYCTL_MOVE Petr Vorel
2026-09-18 11:24   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 16/36] keyctl22: Test KEYCTL_RESTRICT_KEYRING reject-all Petr Vorel
2026-09-18 11:29   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 17/36] lib: tst_test: Move the iterations to struct tst_test Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 18/36] keyctl23: Test KEYCTL_RESTRICT_KEYRING builtin_trusted Petr Vorel
2026-09-18 11:51   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 19/36] keyctl24: Negative tests for KEYCTL_RESTRICT_KEYRING Petr Vorel
2026-09-18 12:08   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 20/36] keyctl25: Test KEYCTL_DH_COMPUTE shared secret computation Petr Vorel
2026-09-18 12:14   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 21/36] keyctl26: Test KEYCTL_DH_COMPUTE size query Petr Vorel
2026-09-18 12:16   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 22/36] keyctl27: Test KEYCTL_DH_COMPUTE KDF key derivation Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 23/36] keyctl28: Negative and boundary tests for KEYCTL_DH_COMPUTE Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 24/36] lapi/keyctl.h: Add fallback definitions for public key ops Petr Vorel
2026-09-18 12:31   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 25/36] keyctl29: Test KEYCTL_PKEY_QUERY on public key Petr Vorel
2026-09-18 14:42   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 26/36] keyctl30: Test KEYCTL_PKEY_QUERY on private key Petr Vorel
2026-09-18 14:50   ` Cyril Hrubis
2026-09-18 16:55     ` Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 27/36] keyctl31: Test KEYCTL_PKEY_ENCRYPT and KEYCTL_PKEY_DECRYPT Petr Vorel
2026-09-18 15:17   ` Cyril Hrubis
2026-09-18 15:53     ` Petr Vorel
2026-09-18 17:01     ` Petr Vorel
2026-09-16 14:03 ` [LTP] [PATCH v3 28/36] keyctl32: Test KEYCTL_PKEY_SIGN and VERIFY Petr Vorel
2026-09-18 15:25   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 29/36] keyctl33: Negative tests for KEYCTL_PKEY_* Petr Vorel
2026-09-18 15:31   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 30/36] lapi/keyctl.h: Add capability fallback defines Petr Vorel
2026-09-18 15:32   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 31/36] keyctl34: Test KEYCTL_CAPABILITIES flag retrieval Petr Vorel
2026-09-18 15:36   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 32/36] keyctl35: Test KEYCTL_CAPABILITIES size query Petr Vorel
2026-09-18 15:37   ` Cyril Hrubis
2026-09-16 14:03 ` [LTP] [PATCH v3 33/36] keyctl36: Test KEYCTL_CAPABILITIES buffer sizing Petr Vorel
2026-09-18 15:44   ` Cyril Hrubis
2026-09-16 14:04 ` [LTP] [PATCH v3 34/36] keyctl37: Negative tests for KEYCTL_CAPABILITIES Petr Vorel
2026-09-16 14:04 ` [LTP] [PATCH v3 35/36] keyctl38: Test KEYCTL_WATCH_KEY add and remove Petr Vorel
2026-09-18 15:53   ` Cyril Hrubis
2026-09-16 14:04 ` [LTP] [PATCH v3 36/36] keyctl39: Negative tests for KEYCTL_WATCH_KEY Petr Vorel
2026-09-17 10:11 ` [LTP] [PATCH v3 00/36] Improve coverage for keyctl() syscall Li Wang
2026-09-18 14:39   ` Petr Vorel
2026-09-19  0:18     ` Li Wang
  -- strict thread matches above, loose matches on Subject: below --
2026-09-04 12:08 [LTP] [PATCH v2 01/33] lapi/keyctl.h: Add fallback definitions for extended ops Andrea Cervesato
2026-09-04 15:18 ` [LTP] " linuxtestproject.agent
2026-09-02 11:04 [LTP] [PATCH 02/33] keyctl10: Test KEYCTL_DESCRIBE format parsing Andrea Cervesato
2026-09-02 14:07 ` [LTP] lapi/keyctl.h: Add fallback definitions for extended ops linuxtestproject.agent

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=20260916181933.4928-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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.