firmware: arm_scmi: use strlcpy to ensure NULL-terminated strings
authorSudeep Holla <sudeep.holla@arm.com>
Fri, 7 Sep 2018 16:03:25 +0000 (17:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:46:14 +0000 (18:46 +0100)
commit4c884128b414e02dad5be3cc510f00215fe64a3e
treee4121f9c11862e52dbf0e77946d0ea5f1f8124c0
parentd786bf93f0c5200296559e878972afc2ea40212d
firmware: arm_scmi: use strlcpy to ensure NULL-terminated strings

[ Upstream commit ca64b719a1e665ac7449b6a968059176af7365a8 ]

Replace all the memcpy() for copying name strings from the firmware with
strlcpy() to make sure we are bounded by the source buffer size and we
also always have NULL-terminated strings.

This is needed to avoid out of bounds accesses if the firmware returns
a non-terminated string.

Reported-by: Olof Johansson <olof@lixom.net>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/arm_scmi/base.c
drivers/firmware/arm_scmi/clock.c
drivers/firmware/arm_scmi/perf.c
drivers/firmware/arm_scmi/power.c
drivers/firmware/arm_scmi/sensors.c