]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
net: hns3: fix strscpy causing content truncation issue
authorHao Chen <chenhao418@huawei.com>
Wed, 9 Aug 2023 02:09:02 +0000 (10:09 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 30 Oct 2023 11:00:06 +0000 (12:00 +0100)
commitd35bfae06610e27a3ab882c99ae0c6cfd733f85d
tree518547eb45469fdf2ec74d313b346bcd4499d668
parentc96215a0155178c4769bff56992da7e2558ff584
net: hns3: fix strscpy causing content truncation issue

BugLink: https://bugs.launchpad.net/bugs/2038969
commit 5e3d20617b055e725e785e0058426368269949f3 upstream.

hns3_dbg_fill_content()/hclge_dbg_fill_content() is aim to integrate some
items to a string for content, and we add '\n' and '\0' in the last
two bytes of content.

strscpy() will add '\0' in the last byte of destination buffer(one of
items), it result in finishing content print ahead of schedule and some
dump content truncation.

One Error log shows as below:
cat mac_list/uc
UC MAC_LIST:

Expected:
UC MAC_LIST:
FUNC_ID  MAC_ADDR            STATE
pf       00:2b:19:05:03:00   ACTIVE

The destination buffer is length-bounded and not required to be
NUL-terminated, so just change strscpy() to memcpy() to fix it.

Fixes: 1cf3d5567f27 ("net: hns3: fix strncpy() not using dest-buf length as length issue")
Signed-off-by: Hao Chen <chenhao418@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Link: https://lore.kernel.org/r/20230809020902.1941471-1-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c