[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dac05a17837275f8224ae3d7bb11f41ed0400682.camel@oracle.com>
Date: Wed, 21 May 2025 17:14:57 +0000
From: Allison Henderson <allison.henderson@...cle.com>
To: "horms@...nel.org" <horms@...nel.org>,
"edumazet@...gle.com"
<edumazet@...gle.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"goralbaris@...il.com" <goralbaris@...il.com>,
"kuba@...nel.org"
<kuba@...nel.org>
CC: "michal.swiatkowski@...ux.intel.com" <michal.swiatkowski@...ux.intel.com>,
"shankari.ak0208@...il.com" <shankari.ak0208@...il.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"skhan@...uxfoundation.org"
<skhan@...uxfoundation.org>
Subject: Re: [PATCH v5 net-next: rds] replace strncpy with strscpy_pad
On Wed, 2025-05-21 at 19:10 +0300, Baris Can Goral wrote:
> The strncpy() function is actively dangerous to use since it may not
> NULL-terminate the destination string, resulting in potential memory
> content exposures, unbounded reads, or crashes.
> Link: https://urldefense.com/v3/__https://github.com/KSPP/linux/issues/90__;!!ACWV5N9M2RV99hQ!PnLUmB9dUMUGdB0dDAEBM6IyoQVEtGLUn755qxSKNTBnGdMzPyDN0cDAS8qijzYFKXnMu3ApLnN0Jc3YBBfCtzh9$
>
> In addition, strscpy_pad is more appropriate because it also zero-fills
> any remaining space in the destination if the source is shorter than
> the provided buffer size.
>
> Signed-off-by: Baris Can Goral <goralbaris@...il.com>
Thanks for the updates, I think this version looks correct now.
Reviewed-by: Allison Henderson <allison.henderson@...cle.com>
> ---
> net/rds/connection.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/net/rds/connection.c b/net/rds/connection.c
> index c749c5525b40..d62f486ab29f 100644
> --- a/net/rds/connection.c
> +++ b/net/rds/connection.c
> @@ -749,8 +749,7 @@ static int rds_conn_info_visitor(struct rds_conn_path *cp, void *buffer)
> cinfo->laddr = conn->c_laddr.s6_addr32[3];
> cinfo->faddr = conn->c_faddr.s6_addr32[3];
> cinfo->tos = conn->c_tos;
> - strncpy(cinfo->transport, conn->c_trans->t_name,
> - sizeof(cinfo->transport));
> + strscpy_pad(cinfo->transport, conn->c_trans->t_name);
> cinfo->flags = 0;
>
> rds_conn_info_set(cinfo->flags, test_bit(RDS_IN_XMIT, &cp->cp_flags),
> @@ -775,8 +774,7 @@ static int rds6_conn_info_visitor(struct rds_conn_path *cp, void *buffer)
> cinfo6->next_rx_seq = cp->cp_next_rx_seq;
> cinfo6->laddr = conn->c_laddr;
> cinfo6->faddr = conn->c_faddr;
> - strncpy(cinfo6->transport, conn->c_trans->t_name,
> - sizeof(cinfo6->transport));
> + strscpy_pad(cinfo6->transport, conn->c_trans->t_name);
> cinfo6->flags = 0;
>
> rds_conn_info_set(cinfo6->flags, test_bit(RDS_IN_XMIT, &cp->cp_flags),
Powered by blists - more mailing lists