drm/i915: refactor deprecated strncpy
authorJustin Stitt <justinstitt@google.com>
Tue, 19 Sep 2023 04:45:31 +0000 (04:45 +0000)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 20 Sep 2023 20:54:56 +0000 (16:54 -0400)
commit5642639bd4f772a09bc4cb05ac7ac9378c2c3f5e
tree925186a32325c57d8db598ac8d4a774285e7d447
parentafddcbe41f049072b3c62d39ce474bd71b3a5212
drm/i915: refactor deprecated strncpy

`strncpy` is deprecated for use on NUL-terminated destination strings [1].

We should prefer more robust and less ambiguous string interfaces.

A suitable replacement is `strscpy` [2] due to the fact that it
guarantees NUL-termination on the destination buffer without
unnecessarily NUL-padding. `ctx` is zero allocated and as such strncpy's
NUL-padding behavior was strictly a performance hit which is now
resolved.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/i915/gem/selftests/mock_context.c