Skip to content

Commit b9c87ce

Browse files
Yunlongsgregkh
authored andcommitted
misc/libmasm/module: Fix two use after free in ibmasm_init_one
[ Upstream commit 7272b59 ] In ibmasm_init_one, it calls ibmasm_init_remote_input_dev(). Inside ibmasm_init_remote_input_dev, mouse_dev and keybd_dev are allocated by input_allocate_device(), and assigned to sp->remote.mouse_dev and sp->remote.keybd_dev respectively. In the err_free_devices error branch of ibmasm_init_one, mouse_dev and keybd_dev are freed by input_free_device(), and return error. Then the execution runs into error_send_message error branch of ibmasm_init_one, where ibmasm_free_remote_input_dev(sp) is called to unregister the freed sp->remote.mouse_dev and sp->remote.keybd_dev. My patch add a "error_init_remote" label to handle the error of ibmasm_init_remote_input_dev(), to avoid the uaf bugs. Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn> Link: https://lore.kernel.org/r/20210426170620.10546-1-lyl2019@mail.ustc.edu.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4f3c807 commit b9c87ce

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/misc/ibmasm/module.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
111111
result = ibmasm_init_remote_input_dev(sp);
112112
if (result) {
113113
dev_err(sp->dev, "Failed to initialize remote queue\n");
114-
goto error_send_message;
114+
goto error_init_remote;
115115
}
116116

117117
result = ibmasm_send_driver_vpd(sp);
@@ -131,8 +131,9 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
131131
return 0;
132132

133133
error_send_message:
134-
disable_sp_interrupts(sp->base_address);
135134
ibmasm_free_remote_input_dev(sp);
135+
error_init_remote:
136+
disable_sp_interrupts(sp->base_address);
136137
free_irq(sp->irq, (void *)sp);
137138
error_request_irq:
138139
iounmap(sp->base_address);

0 commit comments

Comments
 (0)