From: Petr Vorel <pvorel@suse.cz>
To: Richard Palethorpe <rpalethorpe@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] cgroup: Handle trailing new line in cgroup.controllers
Date: Thu, 26 Oct 2023 13:06:59 +0200 [thread overview]
Message-ID: <20231026110659.GA593730@pevik> (raw)
In-Reply-To: <20231026094957.15371-1-rpalethorpe@suse.com>
Hi Richie,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> V2:
> * Add underscore
> * Add length check
> * Expand commit message
> * Use shorter syntax
+1
> lib/tst_cgroup.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
> diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
> index 5240aadaa..c5cb20505 100644
> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -433,9 +433,20 @@ __attribute__ ((nonnull, warn_unused_result))
> static struct cgroup_ctrl *cgroup_find_ctrl(const char *const ctrl_name)
> {
> struct cgroup_ctrl *ctrl;
> + int l = 0;
> + char c = ctrl_name[l];
> +
> + while (c == '_' || (c >= 'a' && c <= 'z'))
> + c = ctrl_name[++l];
> +
> + if (l > 32)
+1 for this check.
I would slightly prefer to add MAX_CGROUP_TYPE_NAMELEN definition into our
include/tst_cgroup.h, but it can stay as is.
BTW include/linux/cgroup-defs.h contains also MAX_CGROUP_ROOT_NAMELEN, there are
also other checks in C files (CGROUP_FILE_NAME_MAX) in case it makes sense to
have some checks for these (I have no idea).
Kind regards,
Petr
> + tst_res(TWARN, "Subsys name len greater than max known value of MAX_CGROUP_TYPE_NAMELEN: %d > 32", l);
> +
> + if (!(c == '\n' || c == '\0'))
> + tst_brk(TBROK, "Unexpected char in %s: %c", ctrl_name, c);
> for_each_ctrl(ctrl) {
> - if (!strcmp(ctrl_name, ctrl->ctrl_name))
> + if (!strncmp(ctrl_name, ctrl->ctrl_name, l))
> return ctrl;
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-10-26 11:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 9:49 [LTP] [PATCH v2] cgroup: Handle trailing new line in cgroup.controllers Richard Palethorpe via ltp
2023-10-26 10:22 ` Marius Kittler
2023-10-26 11:06 ` Petr Vorel [this message]
2023-10-27 8:21 ` Richard Palethorpe
2023-10-27 10:09 ` Petr Vorel
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=20231026110659.GA593730@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=rpalethorpe@suse.com \
/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