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

David Laight
2025-12-23T12:11:11Z

On Tue, 23 Dec 2025 17:29:38 +0800
Li Wang <liwang@redhat.com> wrote:

> David Laight <david.laight.linux@gmail.com> wrote:
>

> > What was wrong with atoi() ?
>
> As the patch summary described, write_to_hugetlbfs previously parsed -s via
> atoi() into an int, which can overflow and print negative sizes. This
> problem was
> found on our kernel-64k platform and
>
> #./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 <--------

So the problem was that atoi() doesn't let you specify valid values
over 2GB.
That isn't how I read the patch summary.
It read as though you were worried about detecting invalid input.

David