From: Leon Romanovsky <leon@kernel.org>
To: Jijie Shao <shaojijie@huawei.com>
Cc: yisen.zhuang@huawei.com, salil.mehta@huawei.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, shenjian15@huawei.com, wangjie125@huawei.com,
liuyonglong@huawei.com, chenhao418@huawei.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net] net: hns3: fix strscpy causing content truncation issue
Date: Wed, 9 Aug 2023 10:03:02 +0300 [thread overview]
Message-ID: <20230809070302.GR94631@unreal> (raw)
In-Reply-To: <20230809020902.1941471-1-shaojijie@huawei.com>
On Wed, Aug 09, 2023 at 10:09:02AM +0800, Jijie Shao wrote:
> From: Hao Chen <chenhao418@huawei.com>
>
> 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.
I think that you should change to strtomem() and not use plain memcpy().
Thanks
next prev parent reply other threads:[~2023-08-09 7:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 2:09 [PATCH net] net: hns3: fix strscpy causing content truncation issue Jijie Shao
2023-08-09 7:03 ` Leon Romanovsky [this message]
2023-08-10 7:45 ` Jijie Shao
2023-08-10 17:22 ` Jakub Kicinski
2023-08-10 18:23 ` Kees Cook
2023-08-10 18:47 ` Jakub Kicinski
2023-08-11 2:28 ` Jijie Shao
2023-08-13 9:05 ` Leon Romanovsky
2023-08-10 18:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230809070302.GR94631@unreal \
--to=leon@kernel.org \
--cc=chenhao418@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=stable@vger.kernel.org \
--cc=wangjie125@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox