Line 4:
Line 4:
This bug was discovered by accident, and in fact it is a real honest-to-goodness software bug that is not only exploitable, but a nuisance during regular use. To understand it, you need to understand how STM works.
This bug was discovered by accident, and in fact it is a real honest-to-goodness software bug that is not only exploitable, but a nuisance during regular use. To understand it, you need to understand how STM works.
â
[[IOS#STM|STM]] (State Transition Manager) is the [[IOS]] module in responsible for some hardware functions like handling the fan, âidleâ ([[WiiConnect24]]) mode, the front slot LED (including the blink patterns), and the front-panel buttons. A main function of STM is to provide a way for PowerPC software to get notifications when either the Reset or the Power buttons are pressed. Itâs worth noting that it is unknown why they did this âthe PowerPC already knows about Reset via the legacy GameCube interface, and can be given direct access to Power including IRQ via the shared GPIO system, and IOS doesnât use these buttons at allâ but they did. It works like this: STM creates two devices, an âimmediateâ device, and an âeventâ device. The immediate device is used to issue commands to STM that take effect immediately, while the event device is the callback mechanism. The PowerPC code issues an IOS_IoctlAsync() call on the âeventâ device, and this call blocks (asynchronously) until there is an event (such as a button press). When this happens, the call returns with the event code, and the PowerPC code reissues it to listen for further events.
+
[[:/dev/stm|STM]] (State Transition Manager) is the [[IOS]] module in responsible for some hardware functions like handling the fan, âidleâ ([[WiiConnect24]]) mode, the front slot LED (including the blink patterns), and the front-panel buttons. A main function of STM is to provide a way for PowerPC software to get notifications when either the Reset or the Power buttons are pressed. Itâs worth noting that it is unknown why they did this âthe PowerPC already knows about Reset via the legacy GameCube interface, and can be given direct access to Power including IRQ via the shared GPIO system, and IOS doesnât use these buttons at allâ but they did. It works like this: STM creates two devices, an âimmediateâ device, and an âeventâ device. The immediate device is used to issue commands to STM that take effect immediately, while the event device is the callback mechanism. The PowerPC code issues an IOS_IoctlAsync() call on the âeventâ device, and this call blocks (asynchronously) until there is an event (such as a button press). When this happens, the call returns with the event code, and the PowerPC code reissues it to listen for further events.
One problem with this approach is that the PowerPC needs a way to shut down the event callback. The IOS [[Hardware/IPC|IPC]] mechanism doesnât provide a way for the PowerPC to cancel an ongoing request; it must wait until its completion. When PowerPC code needs to hand off execution, it needs to clean up all references and file descriptors to IOS, so it needs a way to get rid of the event call. STM implements this by having a call on the immediate interface that forces the event call to return with a zero event code. So far so good. If youâre interested, check out stm.c on libogc (particularly the functions with EventHook in the name).
One problem with this approach is that the PowerPC needs a way to shut down the event callback. The IOS [[Hardware/IPC|IPC]] mechanism doesnât provide a way for the PowerPC to cancel an ongoing request; it must wait until its completion. When PowerPC code needs to hand off execution, it needs to clean up all references and file descriptors to IOS, so it needs a way to get rid of the event call. STM implements this by having a call on the immediate interface that forces the event call to return with a zero event code. So far so good. If youâre interested, check out stm.c on libogc (particularly the functions with EventHook in the name).
Line 17:
Line 17:
| colspan="2" style="text-align: center;" | Initializing STM
| colspan="2" style="text-align: center;" | Initializing STM
|-
|-
â
| open(path=â/dev/stm/immediateâ)
+
| open(path="[[:/dev/stm/immediate]]")
|
|
|-
|-
Line 23:
Line 23:
| open() fd = 1
| open() fd = 1
|-
|-
â
| open(path=â/dev/stm/eventhookâ)
+
| open(path="[[:/dev/stm/eventhook]]")
|
|
|-
|-