mm/damon/core: uninitialized boolean fields in damon_new_scheme()
SJ Park
maintainerHello,
Sashiko reported a bug that I believe a false positive. Sharing the report and why I think it is false in usual mail format, to get help from more eyeballs.
Sashiko report:
https://sashiko.dev/#/bug/linux-b6222b1f-1973-4211-b3cc-048298d29abe
Quoted 10 lines
In
damon_new_scheme(), allocating a new Data Access Monitor (DAMON) scheme object without zero-initializing memory leaves the boolean control fieldscore_filters_allowed,core_filters_default_reject, andops_filters_default_rejectuninitialized.Because the underlying allocator (via
kmalloc_obj) does not clear memory, the allocated struct damos contains garbage values for any field not explicitly set. While most fields are initialized during creation, these three control fields are missed. Although they are typically populated later during kdamond startup,
So, no issue is really happening.
Quoted 4 lines
leaving them uninitialized creates a window
where early access through sysfs or debugfs inspection interfaces evaluates indeterminate state. This results in incorrect state exposure or unintended DAMON filtering logic if evaluated before the daemon fully initializes them.
I understand this is not a report for a real bug, but a recommendation to initialize those fields to prevent possible future bugs. I don't really feel needs to do that for now. In my opinion, doing something that not really necessary in favor of preventing something could only confuse code readers and hide real bugs. We can revisit if any real bug happens.
Quoted 17 lines
// mm/damon/core.c:689-728
struct damos *damon_new_scheme(structdamos_access_pattern*pattern,
enumdamos_actionaction, unsigned longapply_interval_us, structdamos_quota*quota,
structdamos_watermarks*wmarks, inttarget_nid){ struct damos *scheme; scheme = kmalloc_obj(*scheme); if (!scheme) return NULL; scheme->pattern = *pattern; < ... > INIT_LIST_HEAD(&scheme->core_filters);
Quoted 8 lines
INIT_LIST_HEAD(&scheme->ops_filters);
scheme->stat = (struct damos_stat){};
< ... >
scheme->migrate_dests = (struct damos_migrate_dests){};
scheme->target_nid = target_nid;
return scheme;
}Thanks,
SJ
SJ Park
maintainerWays to handle Sashiko bug reports for DAMON (was "Re: [False Bug] mm/damon/core: uninitialized boolean fields in damon_new_scheme()")
Quoted 5 lines · On Sat, 24 Oct 2026 12:52:39 -0700 SJ Park <[email protected]> wrote:
Hello,
Sashiko reported a bug that I believe a false positive. Sharing the report and why I think it is false in usual mail format, to get help from more eyeballs.
I was about to keep doing this for all false positive reports. I added a comment on the Sashiko web ui for this report, closed it, and opened another report that I think a false positive. And I realized this is tedious and not sustainable.
Actually nowadays I was taking time to think about more options. Those include but not limited to making more tooling and just sharing everything on the mailing list and forget about the database. I still find no best option. And I feel like I might spending too much time on this.
Maybe I'm thinking too much. I will just do whatever I feel better to do at the moment. So I might share some Sashiko reports on mailing list or not. Maybe I will start from just not sharing Sashiko reports on mailing list except mentioning those on relevant patch descriptions including Closes: tag. Please don't expect any consistency in my way of Sashiko reports handling for now.
Thanks,
SJ