From: Lee Jones Date: Mon, 2 Nov 2020 14:20:00 +0000 (+0000) Subject: misc: c2port: core: Make copying name from userspace more secure X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e8f50d4bfc8deff61adc74146f130860c4fe356f;p=linux.git 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 Cc: "Eurotech S.p.A" Cc: David Laight Reported-by: Geert Uytterhoeven Acked-by: Arnd Bergmann Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201102142001.560490-1-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index 80d87e8a0bea9..fb9a1b49ff6de 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c @@ -899,7 +899,7 @@ struct c2port_device *c2port_device_register(char *name, unlikely(!ops->c2d_get) || unlikely(!ops->c2d_set)) return ERR_PTR(-EINVAL); - c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL); + c2dev = kzalloc(sizeof(struct c2port_device), GFP_KERNEL); if (unlikely(!c2dev)) return ERR_PTR(-ENOMEM);