summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJustin Stitt <justinstitt@google.com>2023-09-21 07:17:47 +0000
committerLeon Romanovsky <leon@kernel.org>2023-09-22 13:28:54 +0300
commitc2d0c5b28a77d549ea52c70cb828e3ae29dda24d (patch)
treef89d3661468fdac941a9656f332693016f606c4f /mm
parentf0cc82ca116f5b710bc298ea9bbbdb05bae01f5c (diff)
downloadlinux-stable-c2d0c5b28a77d549ea52c70cb828e3ae29dda24d.tar.gz
linux-stable-c2d0c5b28a77d549ea52c70cb828e3ae29dda24d.tar.bz2
linux-stable-c2d0c5b28a77d549ea52c70cb828e3ae29dda24d.zip
IB/hfi1: Replace deprecated strncpy
`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 see that `buf` is expected to be NUL-terminated based on it's use within a trace event wherein `is_misc_err_name` and `is_various_name` map to `is_name` through `is_table`: | TRACE_EVENT(hfi1_interrupt, | TP_PROTO(struct hfi1_devdata *dd, const struct is_table *is_entry, | int src), | TP_ARGS(dd, is_entry, src), | TP_STRUCT__entry(DD_DEV_ENTRY(dd) | __array(char, buf, 64) | __field(int, src) | ), | TP_fast_assign(DD_DEV_ASSIGN(dd); | is_entry->is_name(__entry->buf, 64, | src - is_entry->start); | __entry->src = src; | ), | TP_printk("[%s] source: %s [%d]", __get_str(dev), __entry->buf, | __entry->src) | ); Considering the above, a suitable replacement is `strscpy_pad` due to the fact that it guarantees NUL-termination on the destination buffer while maintaining the NUL-padding behavior that strncpy provides. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] 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/20230921-strncpy-drivers-infiniband-hw-hfi1-chip-c-v1-1-37afcf4964d9@google.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'mm')
0 files changed, 0 insertions, 0 deletions