misc: c2port: core: Make copying name from userspace more secure
authorLee Jones <lee.jones@linaro.org>
Mon, 2 Nov 2020 14:20:00 +0000 (14:20 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Nov 2020 09:12:10 +0000 (10:12 +0100)
commite8f50d4bfc8deff61adc74146f130860c4fe356f
treee9080c1c4cb86d70c8e00bbfab7a6c92758ae673
parentc78c95f919539cad0308e7de0d5d0d656e4a8e98
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: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20201102142001.560490-1-lee.jones@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/c2port/core.c