* [PATCH net-next] devlink: Use after free in devlink_health_reporter_destroy()
@ 2019-01-23 9:44 Dan Carpenter
2019-01-23 9:52 ` Eran Ben Elisha
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-01-23 9:44 UTC (permalink / raw)
To: Jiri Pirko, Eran Ben Elisha; +Cc: David S. Miller, netdev, kernel-janitors
This calls kfree(reporter); before dereferencing reporter on the next
line when it does mutex_unlock(&reporter->devlink->lock);
Fixes: 880ee82f0313 ("devlink: Add health reporter create/destroy functionality")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
net/core/devlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 60248a53c0ad..deccce13285a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4223,14 +4223,16 @@ EXPORT_SYMBOL_GPL(devlink_health_reporter_create);
void
devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
{
- mutex_lock(&reporter->devlink->lock);
+ struct devlink *devlink = reporter->devlink;
+
+ mutex_lock(&devlink->lock);
list_del(&reporter->list);
devlink_health_buffers_destroy(reporter->dump_buffers_array,
DEVLINK_HEALTH_SIZE_TO_BUFFERS(reporter->ops->dump_size));
devlink_health_buffers_destroy(reporter->diagnose_buffers_array,
DEVLINK_HEALTH_SIZE_TO_BUFFERS(reporter->ops->diagnose_size));
kfree(reporter);
- mutex_unlock(&reporter->devlink->lock);
+ mutex_unlock(&devlink->lock);
}
EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] devlink: Use after free in devlink_health_reporter_destroy()
2019-01-23 9:44 [PATCH net-next] devlink: Use after free in devlink_health_reporter_destroy() Dan Carpenter
@ 2019-01-23 9:52 ` Eran Ben Elisha
0 siblings, 0 replies; 2+ messages in thread
From: Eran Ben Elisha @ 2019-01-23 9:52 UTC (permalink / raw)
To: Dan Carpenter, Jiri Pirko
Cc: David S. Miller, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
On 1/23/2019 11:44 AM, Dan Carpenter wrote:
> This calls kfree(reporter); before dereferencing reporter on the next
> line when it does mutex_unlock(&reporter->devlink->lock);
>
> Fixes: 880ee82f0313 ("devlink: Add health reporter create/destroy functionality")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Hi, thanks for the fix.
It is identical to one I posted yesterday.
https://patchwork.ozlabs.org/patch/1029358/
> ---
> net/core/devlink.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index 60248a53c0ad..deccce13285a 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -4223,14 +4223,16 @@ EXPORT_SYMBOL_GPL(devlink_health_reporter_create);
> void
> devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
> {
> - mutex_lock(&reporter->devlink->lock);
> + struct devlink *devlink = reporter->devlink;
> +
> + mutex_lock(&devlink->lock);
> list_del(&reporter->list);
> devlink_health_buffers_destroy(reporter->dump_buffers_array,
> DEVLINK_HEALTH_SIZE_TO_BUFFERS(reporter->ops->dump_size));
> devlink_health_buffers_destroy(reporter->diagnose_buffers_array,
> DEVLINK_HEALTH_SIZE_TO_BUFFERS(reporter->ops->diagnose_size));
> kfree(reporter);
> - mutex_unlock(&reporter->devlink->lock);
> + mutex_unlock(&devlink->lock);
> }
> EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy);
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-23 9:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-23 9:44 [PATCH net-next] devlink: Use after free in devlink_health_reporter_destroy() Dan Carpenter
2019-01-23 9:52 ` Eran Ben Elisha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox