summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHangyu Hua <hbh25y@gmail.com>2022-09-09 04:29:43 +0200
committerLeon Romanovsky <leon@kernel.org>2022-09-20 14:05:29 +0200
commit4b46a6079d2f8a9aa23c96227dfdb8692ac10421 (patch)
tree4013dec4790454a94d0d6a4d3db38e3c0c4571f7
parentRDMA/erdma: Make hardware internal opcodes invisible to driver (diff)
downloadlinux-4b46a6079d2f8a9aa23c96227dfdb8692ac10421.tar.xz
linux-4b46a6079d2f8a9aa23c96227dfdb8692ac10421.zip
RDMA/srpt: Use flex array destination for memcpy()
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> Link: https://lore.kernel.org/r/20220909022943.8896-1-hbh25y@gmail.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Leon Romanovsky <leon@kernel.org>
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 9450c609bf3b..3c3fae738c3e 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;