net/dibs: Correct freeing of dmb_clientid_arr
Subsystems (5)
Alexandra Winter
maintainerPATCH 1/1 net/dibs: Correct freeing of dmb_clientid_arr
A dibs device interrupt handler can be active after dibs_dev_del() and may still access dmb_clientid_arr. (UAF)
In case of a failure in dibs_dev_add() being called by dibs_lo_dev_probe() dmb_clientid_arr is freed twice (double free).
Free dmb_clientid_arr in dibs_dev_release() after last reference is gone. Note that allocating in dibs_dev_add() instead of dibs_dev_alloc() is ok for now, because no dmbs can be registered before dibs_dev_add().
---
This is a squash of [1] and [2] as requested by Jakub.
Simon and Dust Li, I'd appreciate, if you could double-check whether you can give R-b again.
--- drivers/dibs/dibs_loopback.c | 1 - drivers/dibs/dibs_main.c | 14 ++++---------- 2 files changed, 4 insertions(+), 11 deletions(-)
drivers/dibs/dibs_loopback.c +0 -1
@@ -335,7 +335,6 @@ static int dibs_lo_dev_probe(void)return 0 ; err_reg: -kfree (dibs->dmb_clientid_arr);/* pairs with dibs_dev_alloc() */ put_device (&dibs->dev);kfree (ldev);
drivers/dibs/dibs_main.c +4 -10
@@ -128,6 +128,7 @@ static void dibs_dev_release(struct device *dev) dibs = container_of(dev, struct dibs_dev, dev); +kfree (dibs->dmb_clientid_arr);kfree (dibs); }
@@ -194,12 +195,13 @@ int dibs_dev_add(struct dibs_dev *dibs) ret =device_add (&dibs->dev);if (ret) - goto free_client_arr; +return ret; ret =sysfs_create_group (&dibs->dev.kobj, &dibs_dev_attr_group);if (ret) {dev_err (&dibs->dev,"sysfs_create_group failed for dibs_dev\n" ); - goto err_device_del; +device_del (&dibs->dev); +return ret; }mutex_lock (&dibs_dev_list.mutex);mutex_lock (&clients_lock);
@@ -214,13 +216,6 @@ int dibs_dev_add(struct dibs_dev *dibs)mutex_unlock (&dibs_dev_list.mutex);return 0 ; - -err_device_del: -device_del (&dibs->dev); -free_client_arr: -kfree (dibs->dmb_clientid_arr); -return ret; - }EXPORT_SYMBOL_GPL (dibs_dev_add);
@@ -247,7 +242,6 @@ void dibs_dev_del(struct dibs_dev *dibs)mutex_unlock (&dibs_dev_list.mutex);device_del (&dibs->dev); -kfree (dibs->dmb_clientid_arr); }EXPORT_SYMBOL_GPL (dibs_dev_del);
Signature · 1 line
2.39.5 (Apple Git-154)
Alexandra Winter
maintainerQuoted 15 lines · Alexandra Winter
A dibs device interrupt handler can be active after
dibs_dev_del()and may still accessdmb_clientid_arr. (UAF)In case of a failure in
dibs_dev_add()being called bydibs_lo_dev_probe()dmb_clientid_arris freed twice (double free).Free
dmb_clientid_arrindibs_dev_release()after last reference is gone. Note that allocating indibs_dev_add()instead ofdibs_dev_alloc()is ok for now, because no dmbs can be registered beforedibs_dev_add().Fixes cc21191b584c ("dibs: Move data path to dibs layer")Co-developed-by Hidayath Khan <[email protected]>Signed-off-by Hidayath Khan <[email protected]>Signed-off-by Alexandra Winter <[email protected]>
Quoted 8 lines
---
This is a squash of [1] and [2] as requested by Jakub.Simon and Dust Li, I'd appreciate, if you could double-check whether you can give R-b again.
Title should be 'dibs:' instead of 'net/dibs:' for commonality
dibs: Correct freeing of dmb_clientid_arr
Quoted 10 lines · Alexandra Winter
A dibs device interrupt handler can be active after
dibs_dev_del()and may still accessdmb_clientid_arr. (UAF)In case of a failure in
dibs_dev_add()being called bydibs_lo_dev_probe()dmb_clientid_arris freed twice (double free).Free
dmb_clientid_arrindibs_dev_release()after last reference is gone. Note that allocating indibs_dev_add()instead ofdibs_dev_alloc()is ok for now, because no dmbs can be registered beforedibs_dev_add().
Quoted 5 lines
Fixes cc21191b584c ("dibs: Move data path to dibs layer")Co-developed-by Hidayath Khan <[email protected]>Signed-off-by Hidayath Khan <[email protected]>Signed-off-by Alexandra Winter <[email protected]>
Best regards,
Dust
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Mon, 10 Aug 2026 13:14:32 +0200 you wrote:
A dibs device interrupt handler can be active after
dibs_dev_del()and may still accessdmb_clientid_arr. (UAF)In case of a failure in
dibs_dev_add()being called bydibs_lo_dev_probe()dmb_clientid_arris freed twice (double free).Free
dmb_clientid_arrindibs_dev_release()after last reference is gone. Note that allocating indibs_dev_add()instead ofdibs_dev_alloc()is ok for now, because no dmbs can be registered beforedibs_dev_add().[...]
Here is the summary with links:
- [net] net/dibs: Correct freeing of dmb_clientid_arr
https://git.kernel.org/netdev/net/c/9e6869be4906
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html