public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Hangyu Hua <hbh25y@gmail.com>
Cc: bvanassche@acm.org, jgg@ziepe.ca, leon@kernel.org,
	linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] infiniband: ulp: srpt: Use flex array destination for memcpy()
Date: Fri, 9 Sep 2022 10:40:10 +0100	[thread overview]
Message-ID: <YxsJ+n8RjpBIpGKo@work> (raw)
In-Reply-To: <20220909022943.8896-1-hbh25y@gmail.com>

On Fri, Sep 09, 2022 at 10:29:43AM +0800, Hangyu Hua wrote:
> In preparation for FORTIFY_SOURCE performing run-time destination buffer
> bounds checking for memcpy(), specify the destination output buffer
> explicitly, instead of asking memcpy() to write past the end of what looked
> like a fixed-size object.
> 
> Notice that srp_rsp[] is a pointer to a structure that contains
> flexible-array member data[]:
> 
> struct srp_rsp {
> 	...
> 	__be32	sense_data_len;
> 	__be32	resp_data_len;
> 	u8	data[];
> };
> 
> link: https://github.com/KSPP/linux/issues/201
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
--
Gustavo

> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 21cbe30d526f..8c29e14150d3 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -1421,7 +1421,7 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
>  
>  		srp_rsp->flags |= SRP_RSP_FLAG_SNSVALID;
>  		srp_rsp->sense_data_len = cpu_to_be32(sense_data_len);
> -		memcpy(srp_rsp + 1, sense_data, sense_data_len);
> +		memcpy(srp_rsp->data, sense_data, sense_data_len);
>  	}
>  
>  	return sizeof(*srp_rsp) + sense_data_len;
> -- 
> 2.34.1
> 

  reply	other threads:[~2022-09-09  9:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  2:29 [PATCH] infiniband: ulp: srpt: Use flex array destination for memcpy() Hangyu Hua
2022-09-09  9:40 ` Gustavo A. R. Silva [this message]
2022-09-09 16:13 ` Bart Van Assche
2022-09-20 12:11 ` Leon Romanovsky

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=YxsJ+n8RjpBIpGKo@work \
    --to=gustavoars@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=hbh25y@gmail.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=target-devel@vger.kernel.org \
    /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