* [PATCH] infiniband: ulp: srpt: Use flex array destination for memcpy()
@ 2022-09-09 2:29 Hangyu Hua
2022-09-09 9:40 ` Gustavo A. R. Silva
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hangyu Hua @ 2022-09-09 2:29 UTC (permalink / raw)
To: bvanassche, jgg, leon, gustavoars
Cc: linux-rdma, target-devel, linux-kernel, Hangyu Hua
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>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] infiniband: ulp: srpt: Use flex array destination for memcpy()
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
2022-09-09 16:13 ` Bart Van Assche
2022-09-20 12:11 ` Leon Romanovsky
2 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2022-09-09 9:40 UTC (permalink / raw)
To: Hangyu Hua; +Cc: bvanassche, jgg, leon, linux-rdma, target-devel, linux-kernel
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] infiniband: ulp: srpt: Use flex array destination for memcpy()
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
@ 2022-09-09 16:13 ` Bart Van Assche
2022-09-20 12:11 ` Leon Romanovsky
2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2022-09-09 16:13 UTC (permalink / raw)
To: Hangyu Hua, jgg, leon, gustavoars; +Cc: linux-rdma, target-devel, linux-kernel
On 9/8/22 19:29, 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.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] infiniband: ulp: srpt: Use flex array destination for memcpy()
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
2022-09-09 16:13 ` Bart Van Assche
@ 2022-09-20 12:11 ` Leon Romanovsky
2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2022-09-20 12:11 UTC (permalink / raw)
To: Hangyu Hua, gustavoars, jgg, bvanassche
Cc: target-devel, linux-kernel, linux-rdma
On Fri, 9 Sep 2022 10:29:43 +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[]:
>
> [...]
Applied, thanks!
[1/1] infiniband: ulp: srpt: Use flex array destination for memcpy()
https://git.kernel.org/rdma/rdma/c/4b46a6079d2f8a
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-20 12:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-09-09 16:13 ` Bart Van Assche
2022-09-20 12:11 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox