Fix empty tail container detection
Subsystems (2)
PATCH 1/1 Fix empty tail container detection
rv_is_container_monitor() returns false for the last list entry before checking its enable callback. With CONFIG_RV_MON_DEADLINE=y and CONFIG_RV_MON_NOMISS=n, the empty deadline container can be last. Enabling it then calls a NULL callback through rv_enable_single(), causing a kernel oops.
An empty non-tail container already enables successfully: it is marked enabled without activating any child monitors. Preserve this behavior regardless of list position by checking the tail entry's enable callback. Keep the tail check before list_next_entry() to avoid accessing the list head as a monitor.
--- kernel/trace/rv/rv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/rv/rv.c +1 -1
@@ -222,7 +222,7 @@ bool rv_is_container_monitor(struct rv_monitor *mon)struct rv_monitor *next;if (list_is_last (&mon->list, &rv_monitors_list)) -return false; +return !mon->enable; next =list_next_entry (mon, list);
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.53.0
Quoted 12 lines · Avi Weiss
rv_is_container_monitor()returns false for the last list entry before checking its enable callback. WithCONFIG_RV_MON_DEADLINE=yandCONFIG_RV_MON_NOMISS=n, the empty deadline container can be last. Enabling it then calls a NULL callback throughrv_enable_single(), causing a kernel oops.An empty non-tail container already enables successfully: it is marked enabled without activating any child monitors. Preserve this behavior regardless of list position by checking the tail entry's enable callback. Keep the tail check before
list_next_entry()to avoid accessing the list head as a monitor.
Quoted 4 lines
Fixes 8d7861ac507d ("rv: Fix out-of-bound memory access in
rv_is_container_monitor()")Signed-off-by Avi Weiss <[email protected]>---
Well, this is not really a supported configuration, but since we can't easily block it in KConfig and your change is neat and simple, it's still a good addition, thanks.
Quoted 18 lines
kernel/trace/rv/rv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)kernel/trace/rv/rv.c +0
-0@@ -222,7 +222,7 @@ bool rv_is_container_monitor(struct rv_monitor *mon) struct rv_monitor *next;
if (list_is_last(&mon->list, &rv_monitors_list))kernel/trace/rv/rv.c +1
-1-return false; +return !mon->enable;
next =list_next_entry(mon, list);base-commit:
6628e7d4c6b25c8d18f1345e3a20d21829aae7e4