Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v8 1/5] sched_setattr01: Convert to new API
Date: Thu, 10 Sep 2026 12:40:56 +0200	[thread overview]
Message-ID: <aqKJODHqRsBDsSi4@yuki.lan> (raw)
In-Reply-To: <20260904-cve-ghostlock-v8-1-bd999083c7fb@suse.com>

Hi!
> +static void verify_sched_setattr(unsigned int n)
>  {
> -	TEST(sched_setattr(*(test->pid), test->a, test->flags));
> -
> -	if (TEST_RETURN != test->exp_return) {
> -		tst_resm(TFAIL | TTERRNO, "sched_setattr(%i,attr,%u) "
> -		         "returned: %ld expected: %d",
> -		         *(test->pid), test->flags,
> -		         TEST_RETURN, test->exp_return);
> +	struct tcase *tc = &tcases[n];
> +	pid_t pid = tc->pid ? *tc->pid : 0;
> +	struct sched_attr *target_attr = tc->bad_attr ? bad_addr : tc->attr;
> +	struct sched_attr read_attr = { .size = sizeof(read_attr) };
> +
> +	/*
> +	 * The kernel writes sizeof(struct sched_attr) back to uattr->size
> +	 * on the -E2BIG error path, clobbering our test input. Refresh
> +	 * before each call so re-runs (e.g. -i N) still exercise the
> +	 * intended size.
> +	 */
> +	attr_small.size = SCHED_ATTR_SIZE_VER0 - 1;
> +
> +	if (tc->exp_errno) {
> +		TST_EXP_FAIL(sched_setattr(pid, target_attr, tc->flags),
> +			     tc->exp_errno, "%s", tc->desc);
>  		return;
>  	}
>  
> -	if (TEST_ERRNO == test->exp_errno) {
> -		tst_resm(TPASS | TTERRNO,
> -			"sched_setattr() works as expected");
> +	TST_EXP_PASS(sched_setattr(pid, target_attr, tc->flags),
> +		     "%s", tc->desc);
> +	if (!TST_PASS)
>  		return;
> -	}
> -
> -	tst_resm(TFAIL | TTERRNO, "sched_setattr(%i,attr,%u): "
> -		"expected: %d - %s",
> -		*(test->pid), test->flags,
> -		test->exp_errno, tst_strerrno(test->exp_errno));
> -}
> -
> -int main(int argc, char **argv)
> -{
> -	pthread_t thread;
> -	int lc;
>  
> -	tst_parse_opts(argc, argv, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -		pthread_create(&thread, NULL, do_test, NULL);
> -		pthread_join(thread, NULL);
> +	if (sched_getattr(pid, &read_attr, sizeof(read_attr), 0) == -1) {
> +		tst_res(TFAIL | TERRNO, "sched_getattr() failed");
> +		return;
>  	}
>  
> -	tst_exit();
> +	TST_EXP_EQ_LU(read_attr.sched_policy, SCHED_DEADLINE);
> +	TST_EXP_EQ_LU(read_attr.sched_runtime, RUNTIME_VAL);
> +	TST_EXP_EQ_LU(read_attr.sched_deadline, DEADLINE_VAL);
> +	TST_EXP_EQ_LU(read_attr.sched_period, PERIOD_VAL);
> +
> +	reset_sched();
>  }

Can we please split the passing test into a separate testcase?

Mixing possitive and negative tests into single source makes things
more complex for no good reason...

-- 
Cyril Hrubis
chrubis@suse.cz

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

  parent reply	other threads:[~2026-09-10 10:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  7:41 [LTP] [PATCH v8 0/5] Reproducer for ghostlock Andrea Cervesato
2026-09-04  7:41 ` [LTP] [PATCH v8 1/5] sched_setattr01: Convert to new API Andrea Cervesato
2026-09-04  8:20   ` [LTP] " linuxtestproject.agent
2026-09-04  8:23     ` Andrea Cervesato via ltp
2026-09-10 10:40   ` Cyril Hrubis [this message]
2026-09-10 11:58     ` [LTP] [PATCH v8 1/5] " Andrea Cervesato via ltp
2026-09-04  7:41 ` [LTP] [PATCH v8 2/5] sched_getattr01: " Andrea Cervesato
2026-09-10 10:48   ` Cyril Hrubis
2026-09-04  7:41 ` [LTP] [PATCH v8 3/5] lapi/sched: add SAFE_SCHED_SETATTR() Andrea Cervesato
2026-09-10 10:52   ` Cyril Hrubis
2026-09-04  7:41 ` [LTP] [PATCH v8 4/5] lapi/prctl: add more fallback definitions Andrea Cervesato
2026-09-10 10:57   ` Cyril Hrubis
2026-09-04  7:41 ` [LTP] [PATCH v8 5/5] cve: add CVE-2026-43499 reproducer Andrea Cervesato
2026-09-10 11:08   ` 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=aqKJODHqRsBDsSi4@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox