Re: [PATCH] selftests/mm: check stat() return value in khugepaged get_finfo()

Anshuman Tewari <[email protected]>
Newsgroups org.kernel.vger.linux-kselftest,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <CAJqi8kJ8w1HUwU4tR=KZUC+9GMXJjO1-YLqcD9+s_a6tSA9BYQ@mail.gmail.com>
Thanks for the review, SJ — and for the extra maintainer list from
--nogit-fallback, good to know for next time.

Anshuman


On Thu, 20 Aug 2026 at 05:44, SJ Park <[email protected]> wrote:
>
> 'get_maintainer.pl --nogit --nogit-fallback' suggests adding below recipients.
> I added them.
>
> - Zi Yan <[email protected]>
> - Baolin Wang <[email protected]>
> - "Liam R. Howlett" <[email protected]>
> - Nico Pache <[email protected]>
> - Ryan Roberts <[email protected]>
> - Dev Jain <[email protected]>
> - Barry Song <[email protected]>
> - Lance Yang <[email protected]>
> - Usama Arif <[email protected]>
> - Vlastimil Babka <[email protected]>
> - Mike Rapoport <[email protected]>
> - Suren Baghdasaryan <[email protected]>
> - Michal Hocko <[email protected]>
>
> On Wed, 19 Aug 2026 17:44:26 +0530 Anshuman <[email protected]> wrote:
>
> > get_finfo() calls stat() to get metadata about the target directory,
> > but never checks the return value. On failure, stat() returns -1 and
> > leaves path_stat unmodified, so path_stat.st_mode may contain
> > uninitialized stack data.
> >
> > The code then checks S_ISDIR(path_stat.st_mode) against this
> > potentially garbage value. This can produce a misleading "Not a
> > directory" error when the real problem is a nonexistent or
> > inaccessible path, or, in the worst case, the check could pass by
> > chance on garbage data and let the function continue using an
> > invalid path_stat for the rest of its logic.
> >
> > Check the return value and fail with a clear error message if
> > stat() fails, matching the error-handling style already used for
> > statfs() and read_file() later in the same function.
>
> Makes sense to me.
>
> >
> > Signed-off-by: Anshuman <[email protected]>
>
> Reviewed-by: SJ Park <[email protected]>
>
>
> Thanks,
> SJ
>
> [...]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.