čt 15. 1. 2026 v 18:28 odesílatel Wander Lairson Costa
<[email protected]> napsal:
>
> The parse_ns_duration() function currently uses prefix matching for
> detecting time units. This approach is problematic as it silently
> accepts malformed strings such as "100nsx" or "100us_invalid" by
> ignoring the trailing characters, leading to potential configuration
> errors.
>
> Switch to using strcmp() for suffix comparison to enforce exact matches.
> This ensures that the parser strictly validates the time unit and
> rejects any input containing invalid trailing characters, thereby
> improving the robustness of the configuration parsing.
This solution is incorrect. We need to be able to parse deadline
priority correctly, whose format includes two suffixes:
d:runtime[us|ms|s]:period[us|ms|s]
(see manpages)
and is parsed like this:
int parse_prio(char *arg, struct sched_attr *sched_param)
{
...
switch (arg[0]) {
case 'd':
case 'D':
/* d:runtime:period */
if (strlen(arg) < 4)
return -1;
runtime = get_long_ns_after_colon(arg);
if (runtime == INVALID_VAL)
return -1;
period = get_long_ns_after_colon(&arg[2]);
if (period == INVALID_VAL)
return -1;
...
Your commit breaks that:
$ rtla timerlat -P d:10ms:100ms
Invalid -P priority
Tomas