linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
@ 2025-11-13  3:46 Carlos Llamas
  2025-11-13  9:06 ` David Hildenbrand (Red Hat)
  2025-11-13 11:42 ` Mike Rapoport
  0 siblings, 2 replies; 10+ messages in thread
From: Carlos Llamas @ 2025-11-13  3:46 UTC (permalink / raw)
  To: Andrew Morton, Peter Xu, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Ujwal Kundur,
	Brendan Jackman
  Cc: kernel-team, linux-kernel, Carlos Llamas, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
vars into struct") moved some of the operations previously implemented
in uffd_setup_environment() earlier in the main test loop.

The calculation of nr_pages, which involves a division by page_size, now
occurs before checking that default_huge_page_size() returns a non-zero
This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.

Fix this by relocating the non-zero page_size check before the nr_pages
calculation, as it was originally implemented.

Cc: stable@vger.kernel.org
Fixes: 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global vars into struct")
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
 tools/testing/selftests/mm/uffd-unit-tests.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 9e3be2ee7f1b..f917b4c4c943 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1758,10 +1758,15 @@ int main(int argc, char *argv[])
 			uffd_test_ops = mem_type->mem_ops;
 			uffd_test_case_ops = test->test_case_ops;
 
-			if (mem_type->mem_flag & (MEM_HUGETLB_PRIVATE | MEM_HUGETLB))
+			if (mem_type->mem_flag & (MEM_HUGETLB_PRIVATE | MEM_HUGETLB)) {
 				gopts.page_size = default_huge_page_size();
-			else
+				if (gopts.page_size == 0) {
+					uffd_test_skip("huge page size is 0, feature missing?");
+					continue;
+				}
+			} else {
 				gopts.page_size = psize();
+			}
 
 			/* Ensure we have at least 2 pages */
 			gopts.nr_pages = MAX(UFFD_TEST_MEM_SIZE, gopts.page_size * 2)
@@ -1776,12 +1781,6 @@ int main(int argc, char *argv[])
 				continue;
 
 			uffd_test_start("%s on %s", test->name, mem_type->name);
-			if ((mem_type->mem_flag == MEM_HUGETLB ||
-			    mem_type->mem_flag == MEM_HUGETLB_PRIVATE) &&
-			    (default_huge_page_size() == 0)) {
-				uffd_test_skip("huge page size is 0, feature missing?");
-				continue;
-			}
 			if (!uffd_feature_supported(test)) {
 				uffd_test_skip("feature missing");
 				continue;
-- 
2.51.2.1041.gc1ab5b90ca-goog



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13  3:46 [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests Carlos Llamas
@ 2025-11-13  9:06 ` David Hildenbrand (Red Hat)
  2025-11-13  9:54   ` Lorenzo Stoakes
  2025-11-13 11:42 ` Mike Rapoport
  1 sibling, 1 reply; 10+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-13  9:06 UTC (permalink / raw)
  To: Carlos Llamas, Andrew Morton, Peter Xu, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Ujwal Kundur,
	Brendan Jackman
  Cc: kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On 13.11.25 04:46, Carlos Llamas wrote:
> Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> vars into struct") moved some of the operations previously implemented
> in uffd_setup_environment() earlier in the main test loop.
> 
> The calculation of nr_pages, which involves a division by page_size, now
> occurs before checking that default_huge_page_size() returns a non-zero
> This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
> 
> Fix this by relocating the non-zero page_size check before the nr_pages
> calculation, as it was originally implemented.
> 
> Cc: stable@vger.kernel.org

Do we CC stable on unit tests? From my recollection, no.

> Fixes: 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global vars into struct")
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
> ---

Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>

-- 
Cheers

David


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13  9:06 ` David Hildenbrand (Red Hat)
@ 2025-11-13  9:54   ` Lorenzo Stoakes
  2025-11-13 15:01     ` Carlos Llamas
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-11-13  9:54 UTC (permalink / raw)
  To: David Hildenbrand (Red Hat)
  Cc: Carlos Llamas, Andrew Morton, Peter Xu, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Shuah Khan, Ujwal Kundur, Brendan Jackman, kernel-team,
	linux-kernel, stable, open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On Thu, Nov 13, 2025 at 10:06:42AM +0100, David Hildenbrand (Red Hat) wrote:
> On 13.11.25 04:46, Carlos Llamas wrote:
> > Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> > vars into struct") moved some of the operations previously implemented
> > in uffd_setup_environment() earlier in the main test loop.
> >
> > The calculation of nr_pages, which involves a division by page_size, now
> > occurs before checking that default_huge_page_size() returns a non-zero
> > This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
> >
> > Fix this by relocating the non-zero page_size check before the nr_pages
> > calculation, as it was originally implemented.
> >
> > Cc: stable@vger.kernel.org
>
> Do we CC stable on unit tests? From my recollection, no.

Yeah please let's not.

>
> > Fixes: 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global vars into struct")
> > Signed-off-by: Carlos Llamas <cmllamas@google.com>
> > ---
>
> Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>

LGTM so also:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

>
> --
> Cheers
>
> David

Cheers, Lorenzo


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13  3:46 [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests Carlos Llamas
  2025-11-13  9:06 ` David Hildenbrand (Red Hat)
@ 2025-11-13 11:42 ` Mike Rapoport
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Rapoport @ 2025-11-13 11:42 UTC (permalink / raw)
  To: Carlos Llamas
  Cc: Andrew Morton, Peter Xu, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Suren Baghdasaryan,
	Michal Hocko, Shuah Khan, Ujwal Kundur, Brendan Jackman,
	kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On Thu, Nov 13, 2025 at 03:46:22AM +0000, Carlos Llamas wrote:
> Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> vars into struct") moved some of the operations previously implemented
> in uffd_setup_environment() earlier in the main test loop.
> 
> The calculation of nr_pages, which involves a division by page_size, now
> occurs before checking that default_huge_page_size() returns a non-zero
> This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
> 
> Fix this by relocating the non-zero page_size check before the nr_pages
> calculation, as it was originally implemented.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global vars into struct")
> Signed-off-by: Carlos Llamas <cmllamas@google.com>

Agree with what David and Lorenzo said about cc:stable.

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  tools/testing/selftests/mm/uffd-unit-tests.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
> index 9e3be2ee7f1b..f917b4c4c943 100644
> --- a/tools/testing/selftests/mm/uffd-unit-tests.c
> +++ b/tools/testing/selftests/mm/uffd-unit-tests.c
> @@ -1758,10 +1758,15 @@ int main(int argc, char *argv[])
>  			uffd_test_ops = mem_type->mem_ops;
>  			uffd_test_case_ops = test->test_case_ops;
>  
> -			if (mem_type->mem_flag & (MEM_HUGETLB_PRIVATE | MEM_HUGETLB))
> +			if (mem_type->mem_flag & (MEM_HUGETLB_PRIVATE | MEM_HUGETLB)) {
>  				gopts.page_size = default_huge_page_size();
> -			else
> +				if (gopts.page_size == 0) {
> +					uffd_test_skip("huge page size is 0, feature missing?");
> +					continue;
> +				}
> +			} else {
>  				gopts.page_size = psize();
> +			}
>  
>  			/* Ensure we have at least 2 pages */
>  			gopts.nr_pages = MAX(UFFD_TEST_MEM_SIZE, gopts.page_size * 2)
> @@ -1776,12 +1781,6 @@ int main(int argc, char *argv[])
>  				continue;
>  
>  			uffd_test_start("%s on %s", test->name, mem_type->name);
> -			if ((mem_type->mem_flag == MEM_HUGETLB ||
> -			    mem_type->mem_flag == MEM_HUGETLB_PRIVATE) &&
> -			    (default_huge_page_size() == 0)) {
> -				uffd_test_skip("huge page size is 0, feature missing?");
> -				continue;
> -			}
>  			if (!uffd_feature_supported(test)) {
>  				uffd_test_skip("feature missing");
>  				continue;
> -- 
> 2.51.2.1041.gc1ab5b90ca-goog
> 

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13  9:54   ` Lorenzo Stoakes
@ 2025-11-13 15:01     ` Carlos Llamas
  2025-11-13 15:03       ` Lorenzo Stoakes
  0 siblings, 1 reply; 10+ messages in thread
From: Carlos Llamas @ 2025-11-13 15:01 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: David Hildenbrand (Red Hat),
	Andrew Morton, Peter Xu, Liam R. Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Shuah Khan,
	Ujwal Kundur, Brendan Jackman, kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On Thu, Nov 13, 2025 at 09:54:37AM +0000, Lorenzo Stoakes wrote:
> On Thu, Nov 13, 2025 at 10:06:42AM +0100, David Hildenbrand (Red Hat) wrote:
> > On 13.11.25 04:46, Carlos Llamas wrote:
> > > Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> > > vars into struct") moved some of the operations previously implemented
> > > in uffd_setup_environment() earlier in the main test loop.
> > >
> > > The calculation of nr_pages, which involves a division by page_size, now
> > > occurs before checking that default_huge_page_size() returns a non-zero
> > > This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
> > >
> > > Fix this by relocating the non-zero page_size check before the nr_pages
> > > calculation, as it was originally implemented.
> > >
> > > Cc: stable@vger.kernel.org
> >
> > Do we CC stable on unit tests? From my recollection, no.
> 
> Yeah please let's not.

Oops, I keep getting confused about this Cc stable thing. Please let me
know if a v2 dropping the tag is needed.

--
Carlos Llamas


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13 15:01     ` Carlos Llamas
@ 2025-11-13 15:03       ` Lorenzo Stoakes
  2025-11-13 23:32         ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-11-13 15:03 UTC (permalink / raw)
  To: Carlos Llamas
  Cc: David Hildenbrand (Red Hat),
	Andrew Morton, Peter Xu, Liam R. Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Shuah Khan,
	Ujwal Kundur, Brendan Jackman, kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On Thu, Nov 13, 2025 at 03:01:25PM +0000, Carlos Llamas wrote:
> On Thu, Nov 13, 2025 at 09:54:37AM +0000, Lorenzo Stoakes wrote:
> > On Thu, Nov 13, 2025 at 10:06:42AM +0100, David Hildenbrand (Red Hat) wrote:
> > > On 13.11.25 04:46, Carlos Llamas wrote:
> > > > Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> > > > vars into struct") moved some of the operations previously implemented
> > > > in uffd_setup_environment() earlier in the main test loop.
> > > >
> > > > The calculation of nr_pages, which involves a division by page_size, now
> > > > occurs before checking that default_huge_page_size() returns a non-zero
> > > > This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
> > > >
> > > > Fix this by relocating the non-zero page_size check before the nr_pages
> > > > calculation, as it was originally implemented.
> > > >
> > > > Cc: stable@vger.kernel.org
> > >
> > > Do we CC stable on unit tests? From my recollection, no.
> >
> > Yeah please let's not.
>
> Oops, I keep getting confused about this Cc stable thing. Please let me
> know if a v2 dropping the tag is needed.

No need, Andrew should spot the objection and drop the tag :)

>
> --
> Carlos Llamas

Cheers, Lorenzo


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13 15:03       ` Lorenzo Stoakes
@ 2025-11-13 23:32         ` Andrew Morton
  2025-11-14  8:11           ` David Hildenbrand (Red Hat)
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2025-11-13 23:32 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Carlos Llamas, David Hildenbrand (Red Hat),
	Peter Xu, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Ujwal Kundur,
	Brendan Jackman, kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On Thu, 13 Nov 2025 15:03:06 +0000 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:

> On Thu, Nov 13, 2025 at 03:01:25PM +0000, Carlos Llamas wrote:
> > On Thu, Nov 13, 2025 at 09:54:37AM +0000, Lorenzo Stoakes wrote:
> > > On Thu, Nov 13, 2025 at 10:06:42AM +0100, David Hildenbrand (Red Hat) wrote:
> > > > On 13.11.25 04:46, Carlos Llamas wrote:
> > > > > Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> > > > > vars into struct") moved some of the operations previously implemented
> > > > > in uffd_setup_environment() earlier in the main test loop.
> > > > >
> > > > > The calculation of nr_pages, which involves a division by page_size, now
> > > > > occurs before checking that default_huge_page_size() returns a non-zero
> > > > > This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
> > > > >
> > > > > Fix this by relocating the non-zero page_size check before the nr_pages
> > > > > calculation, as it was originally implemented.
> > > > >
> > > > > Cc: stable@vger.kernel.org
> > > >
> > > > Do we CC stable on unit tests? From my recollection, no.
> > >
> > > Yeah please let's not.
> >
> > Oops, I keep getting confused about this Cc stable thing. Please let me
> > know if a v2 dropping the tag is needed.
> 
> No need, Andrew should spot the objection and drop the tag :)

I actually add cc:stable tags to selftests fixes!

Because why not.  Why leave people running known-to-be-buggy code when
our backporting processes are so well-functioning and lightweight?

I'm not getting the objection?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-13 23:32         ` Andrew Morton
@ 2025-11-14  8:11           ` David Hildenbrand (Red Hat)
  2025-11-14 22:39             ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-14  8:11 UTC (permalink / raw)
  To: Andrew Morton, Lorenzo Stoakes
  Cc: Carlos Llamas, Peter Xu, Liam R. Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Shuah Khan,
	Ujwal Kundur, Brendan Jackman, kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On 14.11.25 00:32, Andrew Morton wrote:
> On Thu, 13 Nov 2025 15:03:06 +0000 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
> 
>> On Thu, Nov 13, 2025 at 03:01:25PM +0000, Carlos Llamas wrote:
>>> On Thu, Nov 13, 2025 at 09:54:37AM +0000, Lorenzo Stoakes wrote:
>>>> On Thu, Nov 13, 2025 at 10:06:42AM +0100, David Hildenbrand (Red Hat) wrote:
>>>>> On 13.11.25 04:46, Carlos Llamas wrote:
>>>>>> Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
>>>>>> vars into struct") moved some of the operations previously implemented
>>>>>> in uffd_setup_environment() earlier in the main test loop.
>>>>>>
>>>>>> The calculation of nr_pages, which involves a division by page_size, now
>>>>>> occurs before checking that default_huge_page_size() returns a non-zero
>>>>>> This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.
>>>>>>
>>>>>> Fix this by relocating the non-zero page_size check before the nr_pages
>>>>>> calculation, as it was originally implemented.
>>>>>>
>>>>>> Cc: stable@vger.kernel.org
>>>>>
>>>>> Do we CC stable on unit tests? From my recollection, no.
>>>>
>>>> Yeah please let's not.
>>>
>>> Oops, I keep getting confused about this Cc stable thing. Please let me
>>> know if a v2 dropping the tag is needed.
>>
>> No need, Andrew should spot the objection and drop the tag :)
> 
> I actually add cc:stable tags to selftests fixes!
> 
> Because why not.  Why leave people running known-to-be-buggy code when
> our backporting processes are so well-functioning and lightweight?
> 
> I'm not getting the objection?

I thought we were so inconsistent on that that it ends up being a wasted 
effort to even try taking care about stability of selfests in stable trees.

-- 
Cheers

David


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-14  8:11           ` David Hildenbrand (Red Hat)
@ 2025-11-14 22:39             ` Andrew Morton
  2025-11-17 17:31               ` Ujwal Kundur
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2025-11-14 22:39 UTC (permalink / raw)
  To: David Hildenbrand (Red Hat)
  Cc: Lorenzo Stoakes, Carlos Llamas, Peter Xu, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Shuah Khan, Ujwal Kundur, Brendan Jackman, kernel-team,
	linux-kernel, stable, open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

On Fri, 14 Nov 2025 09:11:40 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote:

> >>> Oops, I keep getting confused about this Cc stable thing. Please let me
> >>> know if a v2 dropping the tag is needed.
> >>
> >> No need, Andrew should spot the objection and drop the tag :)
> > 
> > I actually add cc:stable tags to selftests fixes!
> > 
> > Because why not.  Why leave people running known-to-be-buggy code when
> > our backporting processes are so well-functioning and lightweight?
> > 
> > I'm not getting the objection?
> 
> I thought we were so inconsistent on that that it ends up being a wasted 
> effort to even try taking care about stability of selfests in stable trees.

Oh,  I try to be vigilant about it.

hp2:/usr/src/mm> git log tools/testing/selftests/mm | grep stable@|wc
     44      89    1462

I pass selftests patches through the same brain algorithm as
I do everything else, shrug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests
  2025-11-14 22:39             ` Andrew Morton
@ 2025-11-17 17:31               ` Ujwal Kundur
  0 siblings, 0 replies; 10+ messages in thread
From: Ujwal Kundur @ 2025-11-17 17:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Hildenbrand (Red Hat),
	Lorenzo Stoakes, Carlos Llamas, Peter Xu, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Shuah Khan, Brendan Jackman, kernel-team, linux-kernel, stable,
	open list:MEMORY MANAGEMENT - USERFAULTFD,
	open list:KERNEL SELFTEST FRAMEWORK

> Commit 4dfd4bba8578 ("selftests/mm/uffd: refactor non-composite global
> vars into struct") moved some of the operations previously implemented
> in uffd_setup_environment() earlier in the main test loop.

> The calculation of nr_pages, which involves a division by page_size, now
> occurs before checking that default_huge_page_size() returns a non-zero
> This leads to a division-by-zero error on systems with !CONFIG_HUGETLB.

> Fix this by relocating the non-zero page_size check before the nr_pages
> calculation, as it was originally implemented.

Thanks for the fix! I never tested with CONFIG_HUGETLB turned off. We
now need tests for tests :)

Reviewed-by: Ujwal Kundur <ujwal.kundur@gmail.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-11-17 17:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-13  3:46 [PATCH] selftests/mm: fix division-by-zero in uffd-unit-tests Carlos Llamas
2025-11-13  9:06 ` David Hildenbrand (Red Hat)
2025-11-13  9:54   ` Lorenzo Stoakes
2025-11-13 15:01     ` Carlos Llamas
2025-11-13 15:03       ` Lorenzo Stoakes
2025-11-13 23:32         ` Andrew Morton
2025-11-14  8:11           ` David Hildenbrand (Red Hat)
2025-11-14 22:39             ` Andrew Morton
2025-11-17 17:31               ` Ujwal Kundur
2025-11-13 11:42 ` Mike Rapoport

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox