summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorChaithanya Lagisetty <nagachaithanya9911@gmail.com>2026-09-07 04:52:46 +0000
committerSean Christopherson <seanjc@google.com>2026-09-11 09:35:43 -0700
commit25158cac2d15ae2a3ac1f8791094df9c6522efeb (patch)
treed9870d1810e61d8a68d932813de84f8a84aa979c /tools/perf/scripts/python
parent4e824a04d4fad3f2754d0089fb150c043daab732 (diff)
KVM: selftests: Fix the never-true negative UFFD delay check
demand_paging_test parses the -d option with strtoul() and then asserts that the result is not negative: p.uffd_delay = strtoul(optarg, NULL, 0); TEST_ASSERT(p.uffd_delay >= 0, "A negative UFFD delay is not supported."); p.uffd_delay is a useconds_t, which is an unsigned type, so the comparison is always true and the assertion can never fire. GCC points this out with -Wtype-limits, which is enabled by -Wextra. As a result, "-d -1" is accepted and converted to a very large unsigned delay, causing each demand paging fault to sleep for an unexpectedly long time in usleep() instead of rejecting the argument up front. The return value of strtoul() is not validated either, so a non-numeric argument such as "-d abc" is silently treated as a zero delay. Use atoi_non_negative() instead. It rejects negative values, unparsable input, and trailing garbage. It is already used a few lines below for -v, and hexadecimal input keeps working because atoi_paranoid() also passes a base of 0 to strtol(). Fixes: 0119cb365c93 ("KVM: selftests: Add configurable demand paging delay") Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com> Tested-by: Gautam Menghani <gautam@linux.ibm.com> Reviewed-by: Gautam Menghani <gautam@linux.ibm.com> Link: https://patch.msgid.link/20260907045246.3783304-1-nagachaithanya9911@gmail.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions