Skip to content

Commit 531390a

Browse files
takaswietiwai
authored andcommitted
firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
This patch is fix for Linux kernel v2.6.33 or later. For request subaction to IEC 61883-1 FCP region, Linux FireWire subsystem have had an issue of use-after-free. The subsystem allows multiple user space listeners to the region, while data of the payload was likely released before the listeners execute read(2) to access to it for copying to user space. The issue was fixed by a commit 281e203 ("firewire: core: fix use-after-free regression in FCP handler"). The object of payload is duplicated in kernel space for each listener. When the listener executes ioctl(2) with FW_CDEV_IOC_SEND_RESPONSE request, the object is going to be released. However, it causes memory leak since the commit relies on call of release_request() in drivers/firewire/core-cdev.c. Against the expectation, the function is never called due to the design of release_client_resource(). The function delegates release task to caller when called with non-NULL fourth argument. The implementation of ioctl_send_response() is the case. It should release the object explicitly. This commit fixes the bug. Cc: <[email protected]> Fixes: 281e203 ("firewire: core: fix use-after-free regression in FCP handler") Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 56b88b5 commit 531390a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/firewire/core-cdev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,8 +819,10 @@ static int ioctl_send_response(struct client *client, union ioctl_arg *arg)
819819

820820
r = container_of(resource, struct inbound_transaction_resource,
821821
resource);
822-
if (is_fcp_request(r->request))
822+
if (is_fcp_request(r->request)) {
823+
kfree(r->data);
823824
goto out;
825+
}
824826

825827
if (a->length != fw_get_response_length(r->request)) {
826828
ret = -EINVAL;

0 commit comments

Comments
 (0)