Re: [PATCH v2 1/3] selftests/mm/write_to_hugetlbfs: parse -s as size_t

From: David Hildenbrand (Red Hat)

Date: Sun Dec 21 2025 - 04:01:08 EST


On 12/21/25 09:58, Li Wang wrote:
write_to_hugetlbfs currently parses the -s size argument with atoi()
into an int. This silently accepts malformed input, cannot report overflow,
and can truncate large sizes.

--- Error log ---
# uname -r
6.12.0-xxx.el10.aarch64+64k

# ls /sys/kernel/mm/hugepages/hugepages-*
hugepages-16777216kB/ hugepages-2048kB/ hugepages-524288kB/

#./charge_reserved_hugetlb.sh -cgroup-v2
# -----------------------------------------
...
# nr hugepages = 10
# writing cgroup limit: 5368709120
# writing reseravation limit: 5368709120
...
# Writing to this path: /mnt/huge/test
# Writing this size: -1610612736 <--------


I mean, whoever does that should not expect anything reasonable to happen with these selftests ... so I don't think Fixes: should be added.

Acked-by: David Hildenbrand (Red Hat) <david@xxxxxxxxxx>

--
Cheers

David