Skip to contentSkip to conversation

RDMA/siw: Fix length of first chunk in siw_try_1seg()

PATCH Applied Serhat Kumral 4 participants 4 messages Sep 27 – Sep 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes b9be6f18cf9e ("rdma/siw: transmit path")
Assisted-by LLM
---
 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
index f7dd32c6e5ba..54c9d97015e8 100644
@@ -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
#1 lore raw
Sashiko 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 page

	part = bytes - (PAGE_SIZE - off);

Use the remaining length of the first page as the first chunk.

Fixes b9be6f18cf9e ("rdma/siw: transmit path")
Assisted-by LLM

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
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Serhat Kumral
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 page

	part = bytes - (PAGE_SIZE - off);

Use the remaining length of the first page as the first chunk.

Fixes b9be6f18cf9e ("rdma/siw: transmit path")
Assisted-by LLM
---
  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
index f7dd32c6e5ba..54c9d97015e8 100644

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).

maintainer Applied
#3 lore raw
In reply to Serhat Kumral
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 page

	part = 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 LLM
---
 drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next, thanks

Jason