Re: [PATCH] firmware: arm_scmi: Fix duplicate workqueue name

Sudeep Holla
2020-10-14T16:19:51Z

On Wed, Oct 14, 2020 at 02:48:19PM +0100, Cristian Marussi wrote:

[...]

> >
> > I have pushed a version with above change [1], please check if you are
> > happy with that ?
> >
> > [1] https://git.kernel.org/sudeep.holla/linux/c/b2cd15549b
>
> I agree with the need to retain _notify name, but I'm not so sure about
> the above patch...which is:
>

I agree, I thought about it and just cooked up this as a quick solution.
I will move to that, even I wasn't happy with this TBH.

> diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
> index c24e427dce0d7..f60fa630dd98f 100644
> --- a/drivers/firmware/arm_scmi/notify.c
> +++ b/drivers/firmware/arm_scmi/notify.c
> @@ -1461,6 +1461,7 @@ static const struct scmi_notify_ops notify_ops = {
> int scmi_notification_init(struct scmi_handle *handle)
> {
> void *gid;
> + char scmi_wq_name[32];
> struct scmi_notify_instance *ni;
>
> gid = devres_open_group(handle->dev, NULL, GFP_KERNEL);
> @@ -1474,7 +1475,8 @@ int scmi_notification_init(struct scmi_handle *handle)
> ni->gid = gid;
> ni->handle = handle;
>
> - ni->notify_wq = alloc_workqueue("scmi_notify",
> + sprintf(scmi_wq_name, "%s_notify", dev_name(handle->dev));
> + ni->notify_wq = alloc_workqueue(scmi_wq_name,
> WQ_UNBOUND | WQ_FREEZABLE | WQ_SYSFS,
> 0);
> if (!ni->notify_wq)
>
> ...does not expose a potential buffer overflow given that the dev_name now comes
> from the DT chosen name for this SCMI server instance ?
>
> I'd use snprintf and enlarge a bit the static scmi_wq_name[] to fit a max
> device bane plus "_notify".
>
> Regards
> Cristian