Skip to contentSkip to conversation

RDMA/rxe: Zero the AtomicETH compare field in fetch-and-add requests

PATCH Applied Andrew Stellman 4 participants 4 messages Nov 25 – Nov 26

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

PATCH 1/1 RDMA/rxe: Zero the AtomicETH compare field in fetch-and-add requests

init_req_packet() fills the AtomicETH compare field for compare-and-swap requests but leaves it unwritten for fetch-and-add requests. The field is eight bytes in the transmitted packet.

With init_on_alloc=0, all 200 fetch-and-add requests captured between two rxe devices had nonzero bytes in that field, including printable text. After this change, all 200 had zero there. Compare-and-swap requests sent their compare value before and after the change.

Set the unused compare field to zero when constructing fetch-and-add requests.

The issue was found by Claude Opus 5.5 while checking rxe for other unzeroed memory, as Zhu Yanjun asked in his review of the rxe_mmap_info patch. The fix and this changelog were drafted with OpenAI GPT-6 (Codex) and reviewed by me.

Fixes 8700e3e7c485 ("Soft RoCE driver")

---
A reproducer is available on request.

 drivers/infiniband/sw/rxe/rxe_req.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/sw/rxe/rxe_req.c +1 -0
index 4f353abd76f5..a1e7fa48c665 100644
@@ -483,6 +483,7 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp,
 			atmeth_set_comp(pkt, ibwr->wr.atomic.compare_add);
 		} else {
 			atmeth_set_swap_add(pkt, ibwr->wr.atomic.compare_add);
+			atmeth_set_comp(pkt, 0);
 		}
 		atmeth_set_rkey(pkt, ibwr->wr.atomic.rkey);
 	}
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 12 lines

init_req_packet() fills the AtomicETH compare field for compare-and-swap requests but leaves it unwritten for fetch-and-add requests. The field is eight bytes in the transmitted packet.

With init_on_alloc=0, all 200 fetch-and-add requests captured between two rxe devices had nonzero bytes in that field, including printable text. After this change, all 200 had zero there. Compare-and-swap requests sent their compare value before and after the change.

Set the unused compare field to zero when constructing fetch-and-add requests.

Quoted 8 lines

The issue was found by Claude Opus 5.5 while checking rxe for other unzeroed memory, as Zhu Yanjun asked in his review of the rxe_mmap_info patch. The fix and this changelog were drafted with OpenAI GPT-6 (Codex) and reviewed by me.

Fixes 8700e3e7c485 ("Soft RoCE driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Stellman
Quoted 12 lines · Andrew Stellman

init_req_packet() fills the AtomicETH compare field for compare-and-swap requests but leaves it unwritten for fetch-and-add requests. The field is eight bytes in the transmitted packet.

With init_on_alloc=0, all 200 fetch-and-add requests captured between two rxe devices had nonzero bytes in that field, including printable text. After this change, all 200 had zero there. Compare-and-swap requests sent their compare value before and after the change.

Set the unused compare field to zero when constructing fetch-and-add requests.

Quoted 8 lines

The issue was found by Claude Opus 5.5 while checking rxe for other unzeroed memory, as Zhu Yanjun asked in his review of the rxe_mmap_info patch. The fix and this changelog were drafted with OpenAI GPT-6 (Codex) and reviewed by me.

Fixes 8700e3e7c485 ("Soft RoCE driver")

Thanks a lot. I am fine with this commit.

Zhu Yanjun

Quoted 18 lines

---
A reproducer is available on request.

  drivers/infiniband/sw/rxe/rxe_req.c | 1 +
  1 file changed, 1 insertion(+)
drivers/infiniband/sw/rxe/rxe_req.c +1 -0
index 4f353abd76f5..a1e7fa48c665 100644
@@ -483,6 +483,7 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp,
  			atmeth_set_comp(pkt, ibwr->wr.atomic.compare_add);
  		} else {
  			atmeth_set_swap_add(pkt, ibwr->wr.atomic.compare_add);
+			atmeth_set_comp(pkt, 0);
  		}
  		atmeth_set_rkey(pkt, ibwr->wr.atomic.rkey);
  	}
#3 lore raw
In reply to Andrew Stellman
Quoted 10 lines · Andrew Stellman

init_req_packet() fills the AtomicETH compare field for compare-and-swap requests but leaves it unwritten for fetch-and-add requests. The field is eight bytes in the transmitted packet.

With init_on_alloc=0, all 200 fetch-and-add requests captured between two rxe devices had nonzero bytes in that field, including printable text. After this change, all 200 had zero there. Compare-and-swap requests sent their compare value before and after the change.

[...]

Applied, thanks!

[1/1] RDMA/rxe: Zero the AtomicETH compare field in fetch-and-add requests

      https://git.kernel.org/rdma/rdma/c/d24184a64765d7

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>