RDMA/siw: Fix length of first chunk in siw_try_1seg()
Subsystems (2)
PATCH 1/1 RDMA/siw: Fix length of first chunk in siw_try_1seg()
When a short-single SGE payload crosses a page boundary, siw_try_1seg() computes the length of the first chunk as the amount that spills into the second page instead of the amount left in the first page
part = bytes - (PAGE_SIZE - off);
Use the remaining length of the first page as the first chunk.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
@@ -85,7 +85,7 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)if (likely (PAGE_SIZE - off >= bytes)) {memcpy (paddr, buffer + off, bytes); }else { -unsigned long part = bytes - (PAGE_SIZE - off); +unsigned long part =PAGE_SIZE - off;memcpy (paddr, buffer + off, part);kunmap_local (buffer);
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
When a short-single SGE payload crosses a page boundary,
siw_try_1seg()computes the length of the first chunk as the amount that spills into the second page instead of the amount left in the first pagepart = bytes - (PAGE_SIZE - off);Use the remaining length of the first page as the first chunk.
Fixes b9be6f18cf9e ("rdma/siw: transmit path")Assisted-by LLMSigned-off-by Serhat Kumral <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 20 lines · Serhat Kumral
When a short-single SGE payload crosses a page boundary,
siw_try_1seg()computes the length of the first chunk as the amount that spills into the second page instead of the amount left in the first pagepart = bytes - (PAGE_SIZE - off);Use the remaining length of the first page as the first chunk.
Fixes b9be6f18cf9e ("rdma/siw: transmit path")Assisted-by LLMSigned-off-by Serhat Kumral <[email protected]>--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/sw/siw/siw_qp_tx.c +0
-0
drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 91
Quoted 8 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +1
-1@@ -85,7 +85,7 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)if (likely (PAGE_SIZE - off >= bytes)) {memcpy (paddr, buffer + off, bytes); }else { -unsigned long part = bytes - (PAGE_SIZE - off); +unsigned long part =PAGE_SIZE - off;memcpy (paddr, buffer + off, part);kunmap_local (buffer);
Excellent finding. Thanks very much Serhat.
This is quite serious, since we may copy data from a location beyond the current page (if there are more remaining bytes to be copied in the next page than in the current page).
Quoted 8 lines · Serhat Kumral
When a short-single SGE payload crosses a page boundary,
siw_try_1seg()computes the length of the first chunk as the amount that spills into the second page instead of the amount left in the first pagepart = bytes - (PAGE_SIZE - off);Use the remaining length of the first page as the first chunk.
Quoted 7 lines
Fixes b9be6f18cf9e ("rdma/siw: transmit path")Assisted-by LLMSigned-off-by Serhat Kumral <[email protected]>Acked-by Bernard Metzler <[email protected]>--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to for-next, thanks
Jason