netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rao Shoaib <rao.shoaib@oracle.com>
To: Kees Cook <keescook@chromium.org>, Jay Vosburgh <j.vosburgh@gmail.com>
Cc: kernel test robot <lkp@intel.com>,
	Veaceslav Falico <vfalico@gmail.com>,
	Andy Gospodarek <andy@greyhouse.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] net: bonding: Use strscpy() instead of manually-truncated strncpy()
Date: Wed, 2 Jun 2021 12:46:46 -0700	[thread overview]
Message-ID: <b53fc81b-2348-54f1-72ca-d143d34bf780@oracle.com> (raw)
In-Reply-To: <20210602181133.3326856-1-keescook@chromium.org>

Would it make sense to also replace the other strncpy in the same file.

Shoaib

On 6/2/21 11:11 AM, Kees Cook wrote:
> Silence this warning by just using strscpy() directly:
>
> drivers/net/bonding/bond_main.c:4877:3: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
>      4877 |   strncpy(params->primary, primary, IFNAMSIZ);
>           |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Reported-by: kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/lkml/202102150705.fdR6obB0-lkp@intel.com
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>   drivers/net/bonding/bond_main.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index c5a646d06102..ecfc48f2d0d0 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -5329,10 +5329,8 @@ static int bond_check_params(struct bond_params *params)
>   			(struct reciprocal_value) { 0 };
>   	}
>   
> -	if (primary) {
> -		strncpy(params->primary, primary, IFNAMSIZ);
> -		params->primary[IFNAMSIZ - 1] = 0;
> -	}
> +	if (primary)
> +		strscpy(params->primary, primary, sizeof(params->primary));
>   
>   	memcpy(params->arp_targets, arp_target, sizeof(arp_target));
>   

  reply	other threads:[~2021-06-02 19:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 18:11 [PATCH] net: bonding: Use strscpy() instead of manually-truncated strncpy() Kees Cook
2021-06-02 19:46 ` Rao Shoaib [this message]
2021-06-02 20:02   ` Kees Cook

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=b53fc81b-2348-54f1-72ca-d143d34bf780@oracle.com \
    --to=rao.shoaib@oracle.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=j.vosburgh@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=vfalico@gmail.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;
as well as URLs for NNTP newsgroup(s).