Commit e8f50d4b authored by Lee Jones's avatar Lee Jones Committed by Greg Kroah-Hartman

misc: c2port: core: Make copying name from userspace more secure

Currently the 'c2dev' device data is not initialised when it's
allocated.  There maybe an issue when using strncpy() to populate the
'name' attribute since a NUL terminator may not be provided in all
use-cases.  To prevent such a failing, let's ensure the 'c2dev'
device data area is fully zeroed out on allocation.

Cc: Rodolfo Giometti <giometti@enneenne.com>
Cc: "Eurotech S.p.A" <info@eurotech.it>
Cc: David Laight <David.Laight@aculab.com>
Reported-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20201102142001.560490-1-lee.jones@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c78c95f9
...@@ -899,7 +899,7 @@ struct c2port_device *c2port_device_register(char *name, ...@@ -899,7 +899,7 @@ struct c2port_device *c2port_device_register(char *name,
unlikely(!ops->c2d_get) || unlikely(!ops->c2d_set)) unlikely(!ops->c2d_get) || unlikely(!ops->c2d_set))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL); c2dev = kzalloc(sizeof(struct c2port_device), GFP_KERNEL);
if (unlikely(!c2dev)) if (unlikely(!c2dev))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment