Commit 6e31b75
ring-buffer: Make reading page consistent with the code logic
In the loop of __rb_map_vma(), the 's' variable is calculated from the
same logic that nr_pages is and they both come from nr_subbufs. But the
relationship is not obvious and there's a WARN_ON_ONCE() around the 's'
variable to make sure it never becomes equal to nr_subbufs within the
loop. If that happens, then the code is buggy and needs to be fixed.
The 'page' variable is calculated from cpu_buffer->subbuf_ids[s] which is
an array of 'nr_subbufs' entries. If the code becomes buggy and 's'
becomes equal to or greater than 'nr_subbufs' then this will be an out of
bounds hit before the WARN_ON() is triggered and the code exiting safely.
Make the 'page' initialization consistent with the code logic and assign
it after the out of bounds check.
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Jeongjun Park <[email protected]>
[ sdr: rewrote change log ]
Signed-off-by: Steven Rostedt (Google) <[email protected]>1 parent 0568c6e commit 6e31b75
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7028 | 7028 | | |
7029 | 7029 | | |
7030 | 7030 | | |
7031 | | - | |
| 7031 | + | |
7032 | 7032 | | |
7033 | 7033 | | |
7034 | 7034 | | |
7035 | 7035 | | |
7036 | 7036 | | |
7037 | 7037 | | |
7038 | 7038 | | |
| 7039 | + | |
| 7040 | + | |
7039 | 7041 | | |
7040 | 7042 | | |
7041 | 7043 | | |
| |||
0 commit comments