[LTP] [PATCH v2 7/7] Add lsm_set_self_attr01 test

Cyril Hrubis chrubis@suse.cz
Tue Mar 4 14:26:19 CET 2025


Hi!
> +static void run(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +
> +	/* just in case lsm_set_self_attr() pass , we won't change
> +	 * LSM configuration for the following process
> +	 */
> +	memcpy(ctx, ctx_orig, sizeof(struct lsm_ctx));
> +
> +	ctx_size = page_size;
> +	ctx_size_small = 1;
> +	ctx_size_big = ctx_size + 1;
> +
> +	TST_EXP_FAIL(lsm_set_self_attr(tc->attr, *tc->ctx, *tc->size, tc->flags),
> +	      tc->exp_errno,
> +	      "%s", tc->msg);
> +}
> +
> +static void setup(void)
> +{
> +	int ret;
> +	uint32_t size;
> +
> +	verify_supported_attr_current();
> +
> +	page_size = SAFE_SYSCONF(_SC_PAGESIZE);
> +	size = page_size;
> +
> +	ret = lsm_get_self_attr(LSM_ATTR_CURRENT, ctx_orig, &size, 0);

Here as well, the handling of the size is wrong.

> +	if (ret < 0)
> +		tst_brk(TBROK, "Can't read LSM current attribute");
> +}
> +
> +static struct tst_test test = {
> +	.test = run,
> +	.setup = setup,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.min_kver = "6.8",
> +	.bufs = (struct tst_buffers[]) {
> +		{&ctx, .size = sizeof(struct lsm_ctx)},
> +		{&ctx_orig, .size = sizeof(struct lsm_ctx)},
> +		{}
> +	},
> +};
> 
> -- 
> 2.43.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list