Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Double evaluation of arguments in wait_for_completion macros leads to skipped array indices and memory corruption. - [Medium] Unconditional struct growth of a widely used primitive for a debug feature. - [Medium] Wait event macros skip calling sdt_might_sleep_end() on signal interruptions, leaking DEPT tracking state and stacks. --
commit 5b626a37ee940081b6d37187cde51c2f272e370c Author: Byungchul Park <[email protected]> completion, dept: introduce init_completion_dmap() API Currently, dept uses dept's map embedded in task_struct to track dependencies related to wait_for_completion() and its family. So it doesn't need an explicit map basically. However, for those who want to set the maps with customized class or key, introduce a new API to use external maps. > diff --git a/include/linux/completion.h b/include/linux/completion.h > index 4d8fb1d95c0a6..e50f7d9b4b974 100644 > --- a/include/linux/completion.h > +++ b/include/linux/completion.h > @@ -27,17 +27,15 @@ > struct completion { > unsigned int done; > struct swait_queue_head wait; > + struct dept_map *dmap; > }; [Severity: Medium] Since struct completion is heavily embedded in many kernel data structures, does unconditionally adding the dmap pointer increase the global memory footprint even on production non-debug kernels? Should this new field be guarded by an #ifdef? [ ... ] > @@ -136,13 +140,13 @@ extern void complete_all(struct completion *); > > #define wait_for_completion(x) > \ > ({ \ > - sdt_might_sleep_start_timeout(NULL, -1L); \ > + sdt_might_sleep_start_timeout((x)->dmap, -1L); \ > __wait_for_completion(x); \ > sdt_might_sleep_end(); \ > }) [Severity: High] Does evaluating the argument x multiple times in this macro lead to issues if callers pass an expression with side effects? For example, if a caller like mlx5_vdpa_exec_async_cmds() does: while (completed < issued) wait_for_completion(&cmds[completed++].cmd_done); Would completed++ be executed twice per iteration, skipping array elements and potentially causing out-of-bounds memory accesses? [ ... ] [Severity: Medium] Do wait event macros such as ___wait_event() in include/linux/wait.h skip calling sdt_might_sleep_end() when interrupted by a signal? In include/linux/wait.h:___wait_event(): if (___wait_is_interruptible(state) && __int) { \ __ret = __int; \ goto __out; \ } ... sdt_might_sleep_end(); \ __out: __ret; \ }) If the wait is interrupted by a signal, it escapes via goto __out. Because __out is placed after sdt_might_sleep_end(), it seems the cleanup is skipped. Does this permanently leak the tracking state and its underlying stack objects? -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=32

