* [PATCH v4] media: v4l2-core: fix a use-after-free bug of sd->devnode
@ 2020-02-19 15:25 Dafna Hirschfeld
2020-02-26 14:37 ` Dafna Hirschfeld
0 siblings, 1 reply; 2+ messages in thread
From: Dafna Hirschfeld @ 2020-02-19 15:25 UTC (permalink / raw)
To: linux-media
Cc: dafna.hirschfeld, hverkuil, dafna3, helen.koike, ezequiel,
stable, kernel
sd->devnode is released after calling
v4l2_subdev_release. Therefore it should be set
to NULL so that the subdev won't hold a pointer
to a released object. This fixes a reference
after free bug in function
v4l2_device_unregister_subdev
Cc: stable@vger.kernel.org
Fixes: 0e43734d4c46e ("media: v4l2-subdev: add release() internal op")
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
---
changes since v2:
- since this is a regresion fix, I added Fixes and Cc to stable tags,
- change the commit title and log to be more clear.
changes since v3:
move the sd->devnode = NULL; line below the call to the release cb
so that it can still use it.
drivers/media/v4l2-core/v4l2-device.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 63d6b147b21e..41da73ce2e98 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -179,6 +179,7 @@ static void v4l2_subdev_release(struct v4l2_subdev *sd)
if (sd->internal_ops && sd->internal_ops->release)
sd->internal_ops->release(sd);
+ sd->devnode = NULL;
module_put(owner);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] media: v4l2-core: fix a use-after-free bug of sd->devnode
2020-02-19 15:25 [PATCH v4] media: v4l2-core: fix a use-after-free bug of sd->devnode Dafna Hirschfeld
@ 2020-02-26 14:37 ` Dafna Hirschfeld
0 siblings, 0 replies; 2+ messages in thread
From: Dafna Hirschfeld @ 2020-02-26 14:37 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, dafna3, helen.koike, ezequiel, stable, kernel
Hi,
When a subdevice is registered with
v4l2_async_register_subdev_sensor_common and the main driver is
unloaded and reloaded, it does not register a node for the subdevice
since the devonde is not set to null.
in v4l2_device_register_subdev_nodes the sd is skipped if sd->devnode.
This patch solves this issue as well.
Dafna
On 19.02.20 16:25, Dafna Hirschfeld wrote:
> sd->devnode is released after calling
> v4l2_subdev_release. Therefore it should be set
> to NULL so that the subdev won't hold a pointer
> to a released object. This fixes a reference
> after free bug in function
> v4l2_device_unregister_subdev
>
> Cc: stable@vger.kernel.org
> Fixes: 0e43734d4c46e ("media: v4l2-subdev: add release() internal op")
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
> changes since v2:
> - since this is a regresion fix, I added Fixes and Cc to stable tags,
> - change the commit title and log to be more clear.
>
> changes since v3:
> move the sd->devnode = NULL; line below the call to the release cb
> so that it can still use it.
>
> drivers/media/v4l2-core/v4l2-device.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
> index 63d6b147b21e..41da73ce2e98 100644
> --- a/drivers/media/v4l2-core/v4l2-device.c
> +++ b/drivers/media/v4l2-core/v4l2-device.c
> @@ -179,6 +179,7 @@ static void v4l2_subdev_release(struct v4l2_subdev *sd)
>
> if (sd->internal_ops && sd->internal_ops->release)
> sd->internal_ops->release(sd);
> + sd->devnode = NULL;
> module_put(owner);
> }
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-26 14:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 15:25 [PATCH v4] media: v4l2-core: fix a use-after-free bug of sd->devnode Dafna Hirschfeld
2020-02-26 14:37 ` Dafna Hirschfeld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).