All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
@ 2023-01-17  9:06 ` Takashi Sakamoto
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Sakamoto @ 2023-01-17  9:06 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel, linux1394-devel, linux-kernel

Hi,

This single patch fixes a bug of Linux FireWire subsystem for kernel
v2.6.33 or later. In detail, please refer patch comment.

My intension of this cover-letter is to request sound subsystem maintainer
to send it to mainline since upstream of Linux FireWire subsystem is
already inactive.

To Iwai-san, I would be pleased if you alternatively send it to mainline.


Thanks

Takashi Sakamoto (1):
  firewire: fix memory leak for payload of request subaction to IEC
    61883-1 FCP region

 drivers/firewire/core-cdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.37.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 0/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
@ 2023-01-17  9:06 ` Takashi Sakamoto
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Sakamoto @ 2023-01-17  9:06 UTC (permalink / raw)
  To: tiwai; +Cc: linux1394-devel, linux-kernel, alsa-devel

Hi,

This single patch fixes a bug of Linux FireWire subsystem for kernel
v2.6.33 or later. In detail, please refer patch comment.

My intension of this cover-letter is to request sound subsystem maintainer
to send it to mainline since upstream of Linux FireWire subsystem is
already inactive.

To Iwai-san, I would be pleased if you alternatively send it to mainline.


Thanks

Takashi Sakamoto (1):
  firewire: fix memory leak for payload of request subaction to IEC
    61883-1 FCP region

 drivers/firewire/core-cdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.37.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
  2023-01-17  9:06 ` Takashi Sakamoto
@ 2023-01-17  9:06   ` Takashi Sakamoto
  -1 siblings, 0 replies; 6+ messages in thread
From: Takashi Sakamoto @ 2023-01-17  9:06 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel, linux1394-devel, linux-kernel, stable

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 281e20323ab7 ("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: <stable@vger.kernel.org>
Fixes: 281e20323ab7 ("firewire: core: fix use-after-free regression in FCP handler")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/core-cdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 9c89f7d53e99..958aa4662ccb 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -819,8 +819,10 @@ static int ioctl_send_response(struct client *client, union ioctl_arg *arg)
 
 	r = container_of(resource, struct inbound_transaction_resource,
 			 resource);
-	if (is_fcp_request(r->request))
+	if (is_fcp_request(r->request)) {
+		kfree(r->data);
 		goto out;
+	}
 
 	if (a->length != fw_get_response_length(r->request)) {
 		ret = -EINVAL;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
@ 2023-01-17  9:06   ` Takashi Sakamoto
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Sakamoto @ 2023-01-17  9:06 UTC (permalink / raw)
  To: tiwai; +Cc: linux1394-devel, linux-kernel, alsa-devel, stable

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 281e20323ab7 ("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: <stable@vger.kernel.org>
Fixes: 281e20323ab7 ("firewire: core: fix use-after-free regression in FCP handler")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/core-cdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 9c89f7d53e99..958aa4662ccb 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -819,8 +819,10 @@ static int ioctl_send_response(struct client *client, union ioctl_arg *arg)
 
 	r = container_of(resource, struct inbound_transaction_resource,
 			 resource);
-	if (is_fcp_request(r->request))
+	if (is_fcp_request(r->request)) {
+		kfree(r->data);
 		goto out;
+	}
 
 	if (a->length != fw_get_response_length(r->request)) {
 		ret = -EINVAL;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
  2023-01-17  9:06 ` Takashi Sakamoto
@ 2023-01-17 17:09   ` Takashi Iwai
  -1 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2023-01-17 17:09 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: linux1394-devel, linux-kernel, alsa-devel

On Tue, 17 Jan 2023 10:06:09 +0100,
Takashi Sakamoto wrote:
> 
> Hi,
> 
> This single patch fixes a bug of Linux FireWire subsystem for kernel
> v2.6.33 or later. In detail, please refer patch comment.
> 
> My intension of this cover-letter is to request sound subsystem maintainer
> to send it to mainline since upstream of Linux FireWire subsystem is
> already inactive.
> 
> To Iwai-san, I would be pleased if you alternatively send it to mainline.

OK, I applied it now.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region
@ 2023-01-17 17:09   ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2023-01-17 17:09 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: alsa-devel, linux1394-devel, linux-kernel

On Tue, 17 Jan 2023 10:06:09 +0100,
Takashi Sakamoto wrote:
> 
> Hi,
> 
> This single patch fixes a bug of Linux FireWire subsystem for kernel
> v2.6.33 or later. In detail, please refer patch comment.
> 
> My intension of this cover-letter is to request sound subsystem maintainer
> to send it to mainline since upstream of Linux FireWire subsystem is
> already inactive.
> 
> To Iwai-san, I would be pleased if you alternatively send it to mainline.

OK, I applied it now.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-17 17:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17  9:06 [PATCH 0/1] firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region Takashi Sakamoto
2023-01-17  9:06 ` Takashi Sakamoto
2023-01-17  9:06 ` [PATCH 1/1] " Takashi Sakamoto
2023-01-17  9:06   ` Takashi Sakamoto
2023-01-17 17:09 ` [PATCH 0/1] " Takashi Iwai
2023-01-17 17:09   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.