Public bug reported:

I got a building failure with resolute derivative kernel, in this
kernel, the CONFIG_DAMON is enabled, then I got the building error:

  CC      lib/string.o
In file included from /<<PKGBUILDDIR>>/include/vdso/const.h:5,
                 from /<<PKGBUILDDIR>>/include/linux/const.h:4,
                 from /<<PKGBUILDDIR>>/include/uapi/linux/kernel.h:6,
                 from /<<PKGBUILDDIR>>/include/linux/cache.h:5,
                 from /<<PKGBUILDDIR>>/arch/arm64/include/asm/processor.h:31,
                 from /<<PKGBUILDDIR>>/include/linux/sched.h:13,
                 from /<<PKGBUILDDIR>>/include/linux/cgroup.h:12,
                 from /<<PKGBUILDDIR>>/include/linux/memcontrol.h:13,
                 from /<<PKGBUILDDIR>>/include/linux/damon.h:11,
                 from /<<PKGBUILDDIR>>/mm/damon/core.c:10:
/<<PKGBUILDDIR>>/mm/damon/core.c: In function ‘damon_set_regions’:
/<<PKGBUILDDIR>>/mm/damon/core.c:224:53: error: ‘min_sz_region’ undeclared 
(first use in this function); did you mean ‘damon_sz_region’?
  224 |                 start = ALIGN_DOWN(ranges[i].start, min_sz_region);
      |                                                     ^~~~~~~~~~~~~
/<<PKGBUILDDIR>>/include/uapi/linux/const.h:49:44: note: in definition of macro 
‘__ALIGN_KERNEL_MASK’
   49 | #define __ALIGN_KERNEL_MASK(x, mask)    (((x) + (mask)) & ~(mask))
      |                                            ^
/<<PKGBUILDDIR>>/include/vdso/align.h:9:33: note: in expansion of macro 
‘__ALIGN_KERNEL’
    9 | #define ALIGN_DOWN(x, a)        __ALIGN_KERNEL((x) - ((a) - 1), (a))
      |                                 ^~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/mm/damon/core.c:224:25: note: in expansion of macro 
‘ALIGN_DOWN’
  224 |                 start = ALIGN_DOWN(ranges[i].start, min_sz_region);
      |                         ^~~~~~~~~~
/<<PKGBUILDDIR>>/mm/damon/core.c:224:53: note: each undeclared identifier is 
reported only once for each function it appears in
  224 |                 start = ALIGN_DOWN(ranges[i].start, min_sz_region);
      |                                                     ^~~~~~~~~~~~~
/<<PKGBUILDDIR>>/include/uapi/linux/const.h:49:44: note: in definition of macro 
‘__ALIGN_KERNEL_MASK’
   49 | #define __ALIGN_KERNEL_MASK(x, mask)    (((x) + (mask)) & ~(mask))
      |                                            ^
/<<PKGBUILDDIR>>/include/vdso/align.h:9:33: note: in expansion of macro 
‘__ALIGN_KERNEL’
    9 | #define ALIGN_DOWN(x, a)        __ALIGN_KERNEL((x) - ((a) - 1), (a))
      |                                 ^~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/mm/damon/core.c:224:25: note: in expansion of macro 
‘ALIGN_DOWN’
  224 |                 start = ALIGN_DOWN(ranges[i].start, min_sz_region);
      |                         ^~~~~~~~~~
make[6]: *** [/<<PKGBUILDDIR>>/scripts/Makefile.build:289: mm/damon/core.o] 
Error 1
make[5]: *** [/<<PKGBUILDDIR>>/scripts/Makefile.build:548: mm/damon] Error 2
make[4]: *** [/<<PKGBUILDDIR>>/scripts/Makefile.build:548: mm] Error 2
make[4]: *** Waiting for unfinished jobs....

The culprit commits are introduced in the resolute:7.0.0-38.38, and they are:
commit ca3fcff334db5a711a67e719c9f04ea23312cce8
Author: SJ Park <[email protected]>
Date:   Fri Jul 3 09:56:08 2026 -0700

    mm/damon/core: disallow overlapping input ranges for damon_set_regions()
    
    BugLink: https://bugs.launchpad.net/bugs/2165189
    
    commit 954157679ec34661c2e87e7eb796104a797c32db upstream.
    
    damon_set_regions() assumes the input ranges are sorted by the address and
    don't overlap each other.  Hence the assumption was initially to be
    explicitly validated.  But commit 97d482f4592f ("mm/damon/sysfs: reuse
    damon_set_regions() for regions setting") has mistakenly removed the
    validation.
    
    This can make DAMON behave in unexpected ways.  At the best, the
    monitoring results snapshot will just look weird since there will be
    overlapping regions.  DAMOS will also work weirdly, applying the same
    action multiple times for overlapping regions, and make DAMOS quota weird.
    More seriously, depending on the setup and regions updates sequence,
    negative size regions can be made.  It will trigger WARN_ONCE() if the
    kernel is built with CONFIG_DAMON_DEBUG_SANITY=y.  Depending on the
    monitoring results, the negative size region can further trigger division
    by zero in damon_merge_two_regions().
    
    Note that some of the consequences including the WARN_ONCE() and the
    divide by zero depend on commits that were introduced after the root cause
    commit 97d482f4592f ("mm/damon/sysfs: reuse damon_set_regions() for
    regions setting").
    
    Fix the problems by checking the assumption and returning an error if
    the input ranges don't meet the assumption.
    
    The issue was discovered [1] by Sashiko.
    
    Link: https://lore.kernel.org/[email protected]
    Link: https://lore.kernel.org/[email protected] [1]
    Fixes: 97d482f4592f ("mm/damon/sysfs: reuse damon_set_regions() for regions 
setting")
    Signed-off-by: SJ Park <[email protected]>
    Cc: <[email protected]> # 5.19.x
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: SJ Park <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
    CVE-2026-68164
    Signed-off-by: Alice C. Munduruca <[email protected]>
    Signed-off-by: Edoardo Canepa <[email protected]>

commit 1f2b831fd3135866dd0f6d5d3f74e0e8466a42d8
Author: SJ Park <[email protected]>
Date:   Mon Jun 29 20:52:19 2026 -0700

    mm/damon/core: validate ranges in damon_set_regions()
    
    BugLink: https://bugs.launchpad.net/bugs/2165189
    
    commit 1292c0ecb1caefb8ca064a3639d5673991e8810c upstream.
    
    DAMON core logic assumes zero length regions don't exist.  However, a few
    DAMON API callers including DAMON_SYSFS, DAMON_RECLAIM and DAMON_LRU_SORT
    allow users to set empty monitoring target regions.  This could result in
    WARN_ONCE() on CONFIG_DAMON_DEBUG_SANITY enabled kernel, and
    divide-by-zero from damon_merge_two_regions().
    
    For example, the WANR_ONCE() can be triggered like below.
    
        # grep DAMON_DEBUG_SANITY /boot/config-$(uname -r)
        # CONFIG_DAMON_DEBUG_SANITY=y
        # damo start
        # cd /sys/kernel/mm/damon/admin/kdamonds/0
        # echo 0 > contexts/0/targets/0/regions/0/start
        # echo 0 > contexts/0/targets/0/regions/0/end
        # echo commit > state
        # dmesg
        [....]
        [   73.705780] ------------[ cut here ]------------
        [   73.707552] start 0 >= end 0
        [   73.708452] WARNING: mm/damon/core.c:359 at 
damon_new_region+0x6e/0x80, CPU#1: kdamond.0/758
        [...]
    
    All DAMON API callers eventually use damon_set_regions() to setup the
    regions.  Add the validation logic in the function.
    
    Link: https://lore.kernel.org/[email protected]
    Fixes: 43b0536cb471 ("mm/damon: introduce DAMON-based Reclamation 
(DAMON_RECLAIM)")
    Signed-off-by: SJ Park <[email protected]>
    Cc: Yang yingliang <[email protected]>
    Cc: <[email protected]> # 5.16.x
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: SJ Park <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
    CVE-2026-68165
    Signed-off-by: Alice C. Munduruca <[email protected]>
    Signed-off-by: Edoardo Canepa <[email protected]>


Looks like the min_sz_region should be replaced with min_region_sz.

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: linux (Ubuntu Resolute)
     Importance: Undecided
         Status: New

** Also affects: linux (Ubuntu Resolute)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2168390

Title:
  Build failure on /mm/damon/core.c when CONFIG_DAMON is enabled

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2168390/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to