From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 6/7] Add lsm_list_modules02 test
Date: Wed, 8 Jan 2025 15:05:00 +0100 [thread overview]
Message-ID: <Z36GDDnXQfhzwZvk@yuki.lan> (raw)
In-Reply-To: <20241112-lsm-v1-6-e293a8d99cf6@suse.com>
Hi!
> + if (!name)
> + tst_brk(TBROK, "Unsupported LSM: %lu", ids[i]);
> +
> + if (strstr(name, lsm_list))
Again here the strstr() is not future proof. There is no lsm with the
name as a substring of a different lsm, but it's not entirely unlikely
that a lsm with name that contains one of the three letter names as a
substring in the future.
So I guess that we may as well break the lsm list into an array of
strings with strtok() in the setup and add a function that loops on the
array and does strcmp() for each entry in that array.
> + tst_res(TFAIL, "'%s' has not been found", name);
> + else
> + tst_res(TPASS, "'%s' is enabled", name);
> + }
> +
> + TST_EXP_EQ_LI(*size, counter * sizeof(uint64_t));
So we get literal size in the size and number of elements as the return
value. Sounds good.
> + TST_EXP_EQ_LI(lsm_num, counter);
Isn't this true by definition? We do tst_brk(TBROK, "") on unknown lsm
so if the counter is not increased on each lsm_num iteration we exit the
test with tst_brk() and never reach this line.
And hat is actually missing here is to compare the number of lsm names
in the /sys/kernel/security/lsm file with the lsm_num. But for that we
have to break the file content into tokens and count them, which we need
to do anyways.
> +}
> +
> +static void setup(void)
> +{
> + int fd;
> +
> + page_size = SAFE_SYSCONF(_SC_PAGESIZE);
> + fd = SAFE_OPEN("/sys/kernel/security/lsm", O_RDONLY);
> + SAFE_READ(0, fd, lsm_list, BUFSIZ);
> + SAFE_CLOSE(fd);
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .setup = setup,
> + .min_kver = "6.8",
> + .bufs = (struct tst_buffers []) {
> + {&ids, .size = sizeof(uint64_t) * MAX_LSM_NUM},
> + {&size, .size = sizeof(uint32_t)},
> + {},
> + },
> +};
>
> --
> 2.43.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-01-08 14:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 7:15 [LTP] [PATCH 0/7] LSM testing suite Andrea Cervesato
2024-11-12 7:15 ` [LTP] [PATCH 1/7] Add fallback definitions of LSM syscalls Andrea Cervesato
2024-11-12 8:26 ` Wei Gao via ltp
2024-11-13 23:11 ` Petr Vorel
2024-11-14 1:55 ` Wei Gao via ltp
2024-12-18 18:24 ` Petr Vorel
2024-11-12 7:15 ` [LTP] [PATCH 2/7] Add lsm_get_self_attr01 test Andrea Cervesato
2024-12-18 18:55 ` Petr Vorel
2025-01-07 8:50 ` Andrea Cervesato via ltp
2025-01-08 8:53 ` Andrea Cervesato via ltp
2025-01-08 12:52 ` Cyril Hrubis
2024-11-12 7:15 ` [LTP] [PATCH 3/7] Add lsm_get_self_attr02 test Andrea Cervesato
2025-01-08 12:58 ` Cyril Hrubis
2025-01-08 13:13 ` Andrea Cervesato via ltp
2025-01-08 13:35 ` Cyril Hrubis
2024-11-12 7:15 ` [LTP] [PATCH 4/7] Add lsm_get_self_attr03 test Andrea Cervesato
2024-11-12 7:15 ` [LTP] [PATCH 5/7] Add lsm_list_modules01 test Andrea Cervesato
2025-01-08 13:49 ` Cyril Hrubis
2024-11-12 7:15 ` [LTP] [PATCH 6/7] Add lsm_list_modules02 test Andrea Cervesato
2025-01-08 14:05 ` Cyril Hrubis [this message]
2024-11-12 7:15 ` [LTP] [PATCH 7/7] Add lsm_set_self_attr01 test Andrea Cervesato
2024-12-18 19:03 ` Petr Vorel
2025-01-08 8:50 ` Andrea Cervesato via ltp
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=Z36GDDnXQfhzwZvk@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