Commit f1b0214
committed
console: fix vfs tail follow-mode use-after-free on session disconnect
A command running in follow mode (OCS_RunLoop, e.g. "vfs tail <file>") runs
its Service() loop on its own task, writing to the launching session's
OvmsWriter via a raw pointer. The only stop path was the Ctrl-C Terminator
insert callback. When an SSH/Telnet session was closed or dropped without
Ctrl-C, the console (an OvmsWriter) was destroyed while the task kept running,
so the next writer->write() dereferenced a freed object (zeroed vtable) ->
LoadProhibited crash.
OvmsWriter now tracks its single active follow-mode task (at most one can run,
since input is captured by the Terminator while it runs). TerminateCommandTask()
requests the task to stop (OCS_StopRequested) and waits until it has fully
exited and released the writer; the task clears its registration as its last
writer access. ConsoleSSH/ConsoleTelnet call it before freeing their transport,
with a backstop in ~OvmsWriter(). Cooperative stop+join avoids force-killing a
task mid-write (no vTaskDelete of a task that may hold a lock).
Generic to any OvmsCommandTask, not just vfs tail.1 parent d4d8b57 commit f1b0214
5 files changed
Lines changed: 62 additions & 0 deletions
File tree
- vehicle/OVMS.V3
- components
- console_ssh/src
- console_telnet/src
- main
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
343 | 346 | | |
344 | 347 | | |
345 | 348 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
87 | 118 | | |
88 | 119 | | |
89 | 120 | | |
| |||
1744 | 1775 | | |
1745 | 1776 | | |
1746 | 1777 | | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
1747 | 1781 | | |
1748 | 1782 | | |
| 1783 | + | |
1749 | 1784 | | |
1750 | 1785 | | |
1751 | 1786 | | |
| |||
1772 | 1807 | | |
1773 | 1808 | | |
1774 | 1809 | | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
1775 | 1813 | | |
1776 | 1814 | | |
1777 | 1815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
| |||
98 | 109 | | |
99 | 110 | | |
100 | 111 | | |
| 112 | + | |
101 | 113 | | |
102 | 114 | | |
103 | 115 | | |
| |||
328 | 340 | | |
329 | 341 | | |
330 | 342 | | |
| 343 | + | |
331 | 344 | | |
332 | 345 | | |
333 | 346 | | |
| |||
0 commit comments