linux-stable/drivers/rpmsg
Justin Stitt a9580b9b36 rpmsg: core: Replace deprecated strncpy with strscpy
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

We expect chinfo.name to be NUL-terminated based on its usage with
strncmp():

rpmsg_core.c:
389: if (strncmp(chinfo->name, rpdev->id.name, RPMSG_NAME_SIZE))

Moreover, NUL-padding is not required as chinfo has stack default
initialized all fields to zero:

rpmsg_core.c:
539: struct rpmsg_channel_info chinfo = {};

Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Also, favor the more idiomatic strscpy() usage of:
(dest, src, sizeof(dest)).

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231020-strncpy-drivers-rpmsg-rpmsg_core-c-v1-1-a86b7930c1cf@google.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2023-10-23 11:57:05 -06:00
..
Kconfig rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl 2022-03-13 11:49:53 -05:00
Makefile rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl 2022-03-13 11:49:53 -05:00
mtk_rpmsg.c rpmsg: mtk_rpmsg: Fix circular locking dependency 2022-06-14 16:41:10 -06:00
qcom_glink_native.c rpmsg: glink: Avoid dereferencing NULL channel 2023-07-18 10:12:26 -06:00
qcom_glink_native.h rpmsg: glink: Fix spelling of peek 2023-02-14 20:28:48 -08:00
qcom_glink_rpm.c rpmsg: qcom_glink_rpm: Convert to platform remove callback returning void 2023-04-05 20:58:32 -07:00
qcom_glink_smem.c rpmsg: glink: Fix spelling of peek 2023-02-14 20:28:48 -08:00
qcom_glink_ssr.c rpmsg: move from strlcpy with unused retval to strscpy 2022-12-28 09:47:41 -06:00
qcom_smd.c rpmsg: qcom_smd: Use qcom_smem_is_available() 2023-07-13 22:18:56 -07:00
rpmsg_char.c rpmsg: char: Add RPMSG GET/SET FLOWCONTROL IOCTL support 2023-07-15 11:35:02 -07:00
rpmsg_char.h rpmsg: char: Export eptdev create and destroy functions 2022-03-13 11:49:53 -05:00
rpmsg_core.c rpmsg: core: Replace deprecated strncpy with strscpy 2023-10-23 11:57:05 -06:00
rpmsg_ctrl.c rpmsg: ctrl: Add lock to rpmsg_ctrldev_remove 2022-12-28 09:54:03 -06:00
rpmsg_internal.h rpmsg: core: Add signal API support 2023-07-15 11:34:49 -07:00
rpmsg_ns.c rpmsg: Fix calling device_lock() on non-initialized device 2022-05-06 09:51:33 +02:00
virtio_rpmsg_bus.c rpmsg: virtio: Fix the unregistration of the device rpmsg_ctrl 2022-04-26 09:27:15 -06:00