Commit b3910a7
rtla: Enforce exact match for time unit suffixes
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.
Introduce a match_time_unit() helper that checks the suffix matches
exactly and is followed by either end-of-string or a ':' delimiter.
The ':' is needed because parse_ns_duration() is also called from
get_long_ns_after_colon() when parsing SCHED_DEADLINE priority
specifications in the format "d:runtime:period" (e.g., "d:10ms:100ms").
A plain strcmp() would reject valid deadline strings because the suffix
"ms" is followed by ":100ms", not end-of-string. Similarly,
strncmp_static() would fail because ARRAY_SIZE() includes the NUL
terminator, making it equivalent to strcmp() for this comparison.
The match_time_unit() helper solves both problems: it rejects malformed
input like "100msx" while correctly handling the colon-delimited
deadline format.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Link: https://lore.kernel.org/r/20260309195040.1019085-13-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>1 parent 265905d commit b3910a7
1 file changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
| |||
224 | 239 | | |
225 | 240 | | |
226 | 241 | | |
227 | | - | |
| 242 | + | |
228 | 243 | | |
229 | | - | |
| 244 | + | |
230 | 245 | | |
231 | 246 | | |
232 | | - | |
| 247 | + | |
233 | 248 | | |
234 | 249 | | |
235 | | - | |
| 250 | + | |
236 | 251 | | |
237 | 252 | | |
238 | 253 | | |
| |||
0 commit comments