|WARNING| net: fix signed shift overflow in IPv6 phdr cksum

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Sat Sep 19 11:08:09 CEST 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/169805

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-19

# DPDK Patch Review

## Summary

This patch fixes a signed left shift overflow in `rte_ipv6_phdr_cksum()` where a `uint8_t` protocol field is left-shifted by 24 after implicit promotion to signed `int`, causing undefined behavior for protocol values >= 128.

The fix is correct: casting `ipv6_hdr->proto` to `uint32_t` before the shift ensures the operation is performed in unsigned arithmetic, matching the pattern used in `RTE_IPV4()`.

---

## Findings

### **Errors**: None

### **Warnings**: None

### **Info**

**1. Preferred macro usage**

The fix uses `(uint32_t)ipv6_hdr->proto << 24`, which is correct. However, DPDK provides `RTE_BE32()` for constructing big-endian 32-bit values from byte-swapped components. Consider whether the existing code in this function should use that pattern for consistency with other parts of the codebase.

Note: This is not a requirement for the current patch, which correctly fixes the UB. It's an observation about potential future refactoring for style consistency.

---

## Positive Observations

- **Correct fix**: The cast to `uint32_t` before the shift eliminates the undefined behavior
- **Consistent with existing patterns**: The fix matches `RTE_IPV4()` idiom already used elsewhere
- **Proper scope**: The patch is minimal and focused on fixing the specific UB
- **Appropriate Cc: stable at dpdk.org**: This is a correctness fix suitable for backport
- **Good commit message**: Clearly explains the problem, references UBSan output, and identifies the UB

---

## Conclusion

**This patch is correct and ready for acceptance.** It properly fixes a real signed left shift overflow bug reported by UBSan. The fix is minimal, follows existing DPDK patterns, and does not introduce any new issues.


More information about the test-report mailing list