* [PATCH AUTOSEL 4.19 296/671] staging: android: vsoc: fix copy_from_user overrun
[not found] <20200116170509.12787-1-sashal@kernel.org>
@ 2020-01-16 16:58 ` Sasha Levin
2020-01-16 17:00 ` [PATCH AUTOSEL 4.19 387/671] media: Staging: media: Release the correct resource in an error handling path Sasha Levin
2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 518/671] staging: greybus: light: fix a couple double frees Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-01-16 16:58 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sasha Levin, Greg Kroah-Hartman, devel, Dan Carpenter,
Vincent Stehlé
From: Vincent Stehlé <vincent.stehle@laposte.net>
[ Upstream commit 060ea4271a82270be6d44e8e9aefe8f155fb5626 ]
The `np->permission' structure is smaller than the `np' structure but
sizeof(*np) worth of data is copied in there. Fix the size passed to
copy_from_user() to avoid overrun.
Fixes: 3d2ec9dcd553 ("staging: Android: Add 'vsoc' driver for cuttlefish.")
Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/staging/android/vsoc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c
index 22571abcaa4e..034d86869772 100644
--- a/drivers/staging/android/vsoc.c
+++ b/drivers/staging/android/vsoc.c
@@ -260,7 +260,8 @@ do_create_fd_scoped_permission(struct vsoc_device_region *region_p,
atomic_t *owner_ptr = NULL;
struct vsoc_device_region *managed_region_p;
- if (copy_from_user(&np->permission, &arg->perm, sizeof(*np)) ||
+ if (copy_from_user(&np->permission,
+ &arg->perm, sizeof(np->permission)) ||
copy_from_user(&managed_fd,
&arg->managed_region_fd, sizeof(managed_fd))) {
return -EFAULT;
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 4.19 387/671] media: Staging: media: Release the correct resource in an error handling path
[not found] <20200116170509.12787-1-sashal@kernel.org>
2020-01-16 16:58 ` [PATCH AUTOSEL 4.19 296/671] staging: android: vsoc: fix copy_from_user overrun Sasha Levin
@ 2020-01-16 17:00 ` Sasha Levin
2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 518/671] staging: greybus: light: fix a couple double frees Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-01-16 17:00 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mauro Carvalho Chehab, Sasha Levin, devel, Christophe JAILLET,
linux-media
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
[ Upstream commit 3b6471c7becd06325eb5e701cc2602b2edbbc7b6 ]
'res' is reassigned several times in the function and if we 'goto
error_unmap', its value is not the returned value of 'request_mem_region()'
anymore.
Introduce a new 'struct resource *' variable (i.e. res2) to keep a pointer
to the right resource, if needed in the error handling path.
Fixes: 4b4eda001704 ("Staging: media: Unmap and release region obtained by ioremap_nocache")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 95942768639c..7bf2648affc0 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1777,7 +1777,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)
struct media_pad *pads = &ipipe->pads[0];
struct v4l2_subdev *sd = &ipipe->subdev;
struct media_entity *me = &sd->entity;
- struct resource *res, *memres;
+ struct resource *res, *res2, *memres;
res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
if (!res)
@@ -1791,11 +1791,11 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)
if (!ipipe->base_addr)
goto error_release;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 6);
- if (!res)
+ res2 = platform_get_resource(pdev, IORESOURCE_MEM, 6);
+ if (!res2)
goto error_unmap;
- ipipe->isp5_base_addr = ioremap_nocache(res->start,
- resource_size(res));
+ ipipe->isp5_base_addr = ioremap_nocache(res2->start,
+ resource_size(res2));
if (!ipipe->isp5_base_addr)
goto error_unmap;
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 4.19 518/671] staging: greybus: light: fix a couple double frees
[not found] <20200116170509.12787-1-sashal@kernel.org>
2020-01-16 16:58 ` [PATCH AUTOSEL 4.19 296/671] staging: android: vsoc: fix copy_from_user overrun Sasha Levin
2020-01-16 17:00 ` [PATCH AUTOSEL 4.19 387/671] media: Staging: media: Release the correct resource in an error handling path Sasha Levin
@ 2020-01-16 17:02 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-01-16 17:02 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sasha Levin, devel, greybus-dev, Greg Kroah-Hartman, Dan Carpenter
From: Dan Carpenter <dan.carpenter@oracle.com>
[ Upstream commit 329101244f214952606359d254ae883b7109e1a5 ]
The problem is in gb_lights_request_handler(). If we get a request to
change the config then we release the light with gb_lights_light_release()
and re-allocated it. However, if the allocation fails part way through
then we call gb_lights_light_release() again. This can lead to a couple
different double frees where we haven't cleared out the original values:
gb_lights_light_v4l2_unregister(light);
...
kfree(light->channels);
kfree(light->name);
I also made a small change to how we set "light->channels_count = 0;".
The original code handled this part fine and did not cause a use after
free but it was sort of complicated to read.
Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Link: https://lore.kernel.org/r/20190829122839.GA20116@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/staging/greybus/light.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 010ae1e9c7fb..40680eaf3974 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1098,21 +1098,21 @@ static void gb_lights_channel_release(struct gb_channel *channel)
static void gb_lights_light_release(struct gb_light *light)
{
int i;
- int count;
light->ready = false;
- count = light->channels_count;
-
if (light->has_flash)
gb_lights_light_v4l2_unregister(light);
+ light->has_flash = false;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < light->channels_count; i++)
gb_lights_channel_release(&light->channels[i]);
- light->channels_count--;
- }
+ light->channels_count = 0;
+
kfree(light->channels);
+ light->channels = NULL;
kfree(light->name);
+ light->name = NULL;
}
static void gb_lights_release(struct gb_lights *glights)
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-16 17:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200116170509.12787-1-sashal@kernel.org>
2020-01-16 16:58 ` [PATCH AUTOSEL 4.19 296/671] staging: android: vsoc: fix copy_from_user overrun Sasha Levin
2020-01-16 17:00 ` [PATCH AUTOSEL 4.19 387/671] media: Staging: media: Release the correct resource in an error handling path Sasha Levin
2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 518/671] staging: greybus: light: fix a couple double frees Sasha Levin
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).