mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 03:53:37 +02:00
net/mlx5: fw_tracer, Handle escaped percent properly
The firmware tracer's format string validation and parameter counting
did not properly handle escaped percent signs (%%). This caused
fw_tracer to count more parameters when trace format strings contained
literal percent characters.
To fix it, allow %% to pass string validation and skip %% sequences when
counting parameters since they represent literal percent signs rather
than format specifiers.
Fixes: 70dd6fdb89 ("net/mlx5: FW tracer, parse traces and kernel tracing support")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reported-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Closes: https://lore.kernel.org/netdev/hanz6rzrb2bqbplryjrakvkbmv4y5jlmtthnvi3thg5slqvelp@t3s3erottr6s/
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1765284977-1363052-5-git-send-email-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
b35966042d
commit
c0289f67f7
|
|
@ -368,11 +368,11 @@ static bool mlx5_is_valid_spec(const char *str)
|
|||
while (isdigit(*str) || *str == '#' || *str == '.' || *str == 'l')
|
||||
str++;
|
||||
|
||||
/* Check if it's a valid integer/hex specifier:
|
||||
/* Check if it's a valid integer/hex specifier or %%:
|
||||
* Valid formats: %x, %d, %i, %u, etc.
|
||||
*/
|
||||
if (*str != 'x' && *str != 'X' && *str != 'd' && *str != 'i' &&
|
||||
*str != 'u' && *str != 'c')
|
||||
*str != 'u' && *str != 'c' && *str != '%')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -390,7 +390,11 @@ static bool mlx5_tracer_validate_params(const char *str)
|
|||
if (!mlx5_is_valid_spec(substr + 1))
|
||||
return false;
|
||||
|
||||
substr = strstr(substr + 1, PARAM_CHAR);
|
||||
if (*(substr + 1) == '%')
|
||||
substr = strstr(substr + 2, PARAM_CHAR);
|
||||
else
|
||||
substr = strstr(substr + 1, PARAM_CHAR);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -469,11 +473,15 @@ static int mlx5_tracer_get_num_of_params(char *str)
|
|||
substr = strstr(pstr, VAL_PARM);
|
||||
}
|
||||
|
||||
/* count all the % characters */
|
||||
/* count all the % characters, but skip %% (escaped percent) */
|
||||
substr = strstr(str, PARAM_CHAR);
|
||||
while (substr) {
|
||||
num_of_params += 1;
|
||||
str = substr + 1;
|
||||
if (*(substr + 1) != '%') {
|
||||
num_of_params += 1;
|
||||
str = substr + 1;
|
||||
} else {
|
||||
str = substr + 2;
|
||||
}
|
||||
substr = strstr(str, PARAM_CHAR);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user