Commit 782da41
committed
netdevsim: Fix memory leak of nsim_dev->fa_cookie
jira VULN-65787
cve CVE-2022-49803
commit-author Wang Yufen <[email protected]>
commit 064bc73
upstream-diff
1. The modified upstream function was `nsim_drv_remove', here it's
`nsim_dev_remove' - the renaming was done in
a66f64b.
2. In the upstream the `kfree' calls are right after
`devl_unregister(devlink)'. The corresponding call in LTS 8.6 is
`devlink_unregister(devlink)' (see commit
9053637).
3. Unlike in the upstream the `kfree' calls in LTS 8.6 don't include
`kfree(nsim_dev->vfconfigs)', because the `vfconfgis' is not yet
managed by `nsim_dev' (see commit
5e388f3).
kmemleak reports this issue:
unreferenced object 0xffff8881bac872d0 (size 8):
comm "sh", pid 58603, jiffies 4481524462 (age 68.065s)
hex dump (first 8 bytes):
04 00 00 00 de ad be ef ........
backtrace:
[<00000000c80b8577>] __kmalloc+0x49/0x150
[<000000005292b8c6>] nsim_dev_trap_fa_cookie_write+0xc1/0x210 [netdevsim]
[<0000000093d78e77>] full_proxy_write+0xf3/0x180
[<000000005a662c16>] vfs_write+0x1c5/0xaf0
[<000000007aabf84a>] ksys_write+0xed/0x1c0
[<000000005f1d2e47>] do_syscall_64+0x3b/0x90
[<000000006001c6ec>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
The issue occurs in the following scenarios:
nsim_dev_trap_fa_cookie_write()
kmalloc() fa_cookie
nsim_dev->fa_cookie = fa_cookie
..
nsim_drv_remove()
The fa_cookie allocked in nsim_dev_trap_fa_cookie_write() is not freed. To
fix, add kfree(nsim_dev->fa_cookie) to nsim_drv_remove().
Fixes: d3cbb90 ("netdevsim: add ACL trap reporting cookie as a metadata")
Signed-off-by: Wang Yufen <[email protected]>
Cc: Jiri Pirko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
(cherry picked from commit 064bc73)
Signed-off-by: Marcin Wcisło <[email protected]>1 parent 98830ec commit 782da41
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1569 | 1569 | | |
1570 | 1570 | | |
1571 | 1571 | | |
| 1572 | + | |
1572 | 1573 | | |
1573 | 1574 | | |
1574 | 1575 | | |
| |||
0 commit comments