summaryrefslogtreecommitdiff
path: root/net/lapb/lapb_timer.c
diff options
context:
space:
mode:
authorJustin Stitt <justinstitt@google.com>2023-09-21 07:58:48 +0000
committerLeon Romanovsky <leon@kernel.org>2023-09-22 13:29:19 +0300
commitcb7ab7854bc70942abed62d19d8c16d0064bf7dc (patch)
treec1249d3ed86bb24c78ae2154e97f81a9a87e27a2 /net/lapb/lapb_timer.c
parentc2d0c5b28a77d549ea52c70cb828e3ae29dda24d (diff)
IB/qib: 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 know `txselect_list` is expected to be NUL-terminated based on its use in `param_get_string()`: | int param_get_string(char *buffer, const struct kernel_param *kp) | { | const struct kparam_string *kps = kp->str; | return scnprintf(buffer, PAGE_SIZE, "%s\n", kps->string); | } Note that `txselect_list` is assigned to `kp_txselect`'s string field: | static struct kparam_string kp_txselect = { | .string = txselect_list, | .maxlen = MAX_ATTEN_LEN | }; Wherein it is then assigned the set and get methods: | module_param_call(txselect, setup_txselect, param_get_string, | &kp_txselect, S_IWUSR | S_IRUGO); 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. 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/20230921-strncpy-drivers-infiniband-hw-qib-qib_iba7322-c-v1-1-373727763f5b@google.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'net/lapb/lapb_timer.c')
0 files changed, 0 insertions, 0 deletions