Commit a0bfd3b
module: Fix memory deallocation on error path in move_module()
BugLink: https://bugs.launchpad.net/bugs/2123745
[ Upstream commit ca3881f6fd8e9b6eb2d51e8718d07d3b8029d886 ]
The function move_module() uses the variable t to track how many memory
types it has allocated and consequently how many should be freed if an
error occurs.
The variable is initially set to 0 and is updated when a call to
module_memory_alloc() fails. However, move_module() can fail for other
reasons as well, in which case t remains set to 0 and no memory is freed.
Fix the problem by initializing t to MOD_MEM_NUM_TYPES. Additionally, make
the deallocation loop more robust by not relying on the mod_mem_type_t enum
having a signed integer as its underlying type.
Fixes: c7ee8ae ("module: add stop-grap sanity check on module memcpy()")
Signed-off-by: Petr Pavlu <[email protected]>
Reviewed-by: Sami Tolvanen <[email protected]>
Reviewed-by: Daniel Gomez <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Daniel Gomez <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
[nwager: Context change due to missing commit:
c287c0723329 ("module: switch to execmem API for remapping as RW and restoring ROX")]
Signed-off-by: Noah Wager <[email protected]>
Signed-off-by: Edoardo Canepa <[email protected]>1 parent 0a4f611 commit a0bfd3b
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2635 | 2635 | | |
2636 | 2636 | | |
2637 | 2637 | | |
2638 | | - | |
| 2638 | + | |
2639 | 2639 | | |
2640 | 2640 | | |
2641 | 2641 | | |
| |||
2717 | 2717 | | |
2718 | 2718 | | |
2719 | 2719 | | |
2720 | | - | |
| 2720 | + | |
2721 | 2721 | | |
2722 | 2722 | | |
2723 | 2723 | | |
| |||
0 commit comments