public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Marat Khalili <marat.khalili@huawei.com>
Cc: <jerinjacobk@gmail.com>, <mb@smartsharesystems.com>,
	<dev@dpdk.org>, <stable@dpdk.org>,
	<konstantin.ananyev@huawei.com>
Subject: Re: [PATCH v3 0/6] bpf: simple tests and fixes
Date: Thu, 22 Jan 2026 21:22:40 -0800	[thread overview]
Message-ID: <20260122212240.3ad5344d@phoenix.local> (raw)
In-Reply-To: <20251217180141.60227-1-marat.khalili@huawei.com>

On Wed, 17 Dec 2025 18:01:33 +0000
Marat Khalili <marat.khalili@huawei.com> wrote:

> Add simple unit-style tests for rte_bpf_load, and fix some minor
> discovered bugs.
> 
> v3:
> * Fixed unfortunate typos in the last patch commit message.
> * Marked all ARM opcodes with UINT32_C for clarity as suggested by
>   Morten Brørup, in a separate commit.
> 
> v2:
> * Moved new tests back into test_bpf.c
> * Changed library macros RTE_SHIFT_VALxx to handle variable first
>   arguments instead of introducing new macros.
> * Added another test and fix, for conditional jump as first instruction.
> 
> Marat Khalili (6):
>   eal: variable first arguments of RTE_SHIFT_VALxx
>   bpf: fix signed shift overflows in ARM JIT
>   bpf: mark ARM opcodes with UINT32_C
>   bpf: disallow empty program
>   bpf: make add/subtract one program validate
>   bpf: fix BPF validation w/ conditional jump first
> 
>  app/test/test_bpf.c          | 254 +++++++++++++++++++++++++++++++++++
>  lib/bpf/bpf_jit_arm64.c      | 184 ++++++++++++-------------
>  lib/bpf/bpf_load.c           |   2 +-
>  lib/bpf/bpf_validate.c       |  48 ++++---
>  lib/eal/include/rte_bitops.h |   4 +-
>  5 files changed, 375 insertions(+), 117 deletions(-)


AI patch review saw some really minor things.
These can be fixed by new version or by maintainer during merge.
It would be good to be consistent about Fixes and Cc: stable.

Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org>

=== Patch Review: bundle-1681-bpf-fixes.mbox (via Claude) ===
# DPDK Patch Review: bundle-1681-bpf-fixes.mbox

## Overview
This patch series (6 patches) addresses BPF-related fixes including signed shift overflows in ARM JIT, validation improvements, and related EAL macro changes.

---

## Patch 1/6: eal: variable first arguments of RTE_SHIFT_VALxx

### Errors
None identified.

### Warnings

1. **Missing Cc: stable@dpdk.org in commit message body**
   - The patch CC's `stable@dpdk.org` in email headers but should include `Cc: stable@dpdk.org` in the commit message body if this is intended for stable backport.

### Info

1. **Good practice**: The parenthetical note about `uint_least64_t` vs `uint64_t` is helpful context for reviewers.

2. **Change is appropriate**: Replacing `UINT32_C`/`UINT64_C` with casts allows variable arguments while maintaining the intended type behavior.

---

## Patch 2/6: bpf: fix signed shift overflows in ARM JIT

### Errors
None identified.

### Warnings

1. **Missing Fixes: tag** - This patch fixes a bug (signed shift overflow causing undefined behavior). It should have a `Fixes:` tag with the 12-character SHA of the commit that introduced the problematic code.
   ```
   Fixes: abcdef123456 ("bpf: add JIT support for arm64")
   ```

2. **Missing Cc: stable@dpdk.org in commit body** - If this is a bug fix intended for stable releases, it should have `Cc: stable@dpdk.org` in the commit message.

3. **Trailing whitespace in Acked-by tag** (line with `Acked-by: Konstantin Ananyev`):
   ```
   Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> 
   ```
   There appears to be a trailing space after the closing `>`.

### Info

1. **Good use of RTE macros**: Using `RTE_BIT32()` and `RTE_SHIFT_VAL32()` is the correct approach to avoid signed integer overflow UB.

2. **Dependency**: This patch depends on Patch 1/6 for `RTE_SHIFT_VAL32` to accept non-constant arguments.

---

## Patch 3/6: bpf: mark ARM opcodes with UINT32_C

### Errors
None identified.

### Warnings

1. **Missing Cc: stable@dpdk.org** - Similar to patch 2, if this is fixing potential issues, it may warrant stable backport consideration.

### Info

1. **Good practice**: Explicitly marking opcode constants with `UINT32_C()` clarifies intent and ensures consistent unsigned 32-bit operations.

2. **Minor style observation**: The parentheses around macro definitions like `#define A64_CMP (UINT32_C(0x6b00000f))` are good defensive practice.

---

## Patch 4/6: bpf: disallow empty program

### Errors
None identified.

### Warnings

1. **Missing Fixes: tag** - The commit message mentions fixing bugs:
   > Fix found bugs:
   > * a program with no instructions was accepted;
   > * a program with no EXIT instruction read outside the buffer.
   
   These should have corresponding `Fixes:` tags.

2. **Missing Cc: stable@dpdk.org** - Bug fixes should typically be considered for stable backport.

3. **Brace style inconsistency** (app/test/test_bpf.c, line 90-93):
   ```c
   if (expected_errno != 0) {
           ...
   } else
           RTE_TEST_ASSERT_NOT_EQUAL(...);
   ```
   While this follows DPDK style for single-statement else, the asymmetry with the braced if-block could be considered less readable.

### Info

1. **Good test coverage**: Adding tests for edge cases (empty program, EXIT-only, no-EXIT, minimal valid) is excellent practice.

2. **Use of RTE_TEST_ASSERT macros**: Good use of the test framework macros.

3. **Comment style**: The function-level comments are well-written and follow proper multi-line comment format.

---

## Patch 5/6: bpf: make add/subtract one program validate

### Errors
None identified.

### Warnings

1. **Missing Fixes: tag** - This fixes signed integer overflow UB in `bpf_validate.c`. Should include:
   ```
   Fixes: <sha> ("original commit that introduced the bug")
   ```

2. **Missing Cc: stable@dpdk.org** - Bug fix should be considered for stable.

### Info

1. **Correct fix approach**: Casting to `uint64_t` before arithmetic is the right way to handle potential signed overflow when the result will be masked anyway.

2. **Good test additions**: Tests for add/subtract operations validate the fix works correctly.

---

## Patch 6/6: bpf: fix BPF validation w/ conditional jump first

### Errors
None identified.

### Warnings

1. **Trailing whitespace in Tested-by tag**:
   ```
   Tested-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> 
   ```
   There appears to be trailing space after `>`.

2. **Subject line could be clearer** - "fix BPF validation w/ conditional jump first" is somewhat abbreviated. Consider:
   ```
   bpf: fix validation when conditional jump is first instruction
   ```

### Info

1. **Good Fixes: tag present**: `Fixes: 6e12ec4c4d6d ("bpf: add more checks")` - properly formatted.

2. **Excellent commit message**: Clear explanation of the bug (zero index used as sentinel), the root cause, and the fix approach.

3. **Good test coverage**: Two tests demonstrating the issue - one with jump as first instruction, one with jump as non-first instruction to prevent regression.

4. **Code change is sound**: Switching from index-based to pointer-based tracking for `prev_node` is cleaner and avoids the zero-sentinel problem.

---

## Summary

| Patch | Errors | Warnings | Info |
|-------|--------|----------|------|
| 1/6 (eal) | 0 | 1 | 2 |
| 2/6 (bpf ARM) | 0 | 3 | 2 |
| 3/6 (bpf opcodes) | 0 | 1 | 2 |
| 4/6 (bpf empty) | 0 | 3 | 3 |
| 5/6 (bpf add/sub) | 0 | 2 | 2 |
| 6/6 (bpf jump) | 0 | 2 | 4 |

### Key Issues to Address

1. **Missing Fixes: tags** on patches 2, 3, 4, and 5 - these are bug fixes and should reference the original commits.

2. **Missing Cc: stable@dpdk.org** in commit message bodies for bug fix patches.

3. **Trailing whitespace** in Acked-by/Tested-by lines on patches 2 and 6.

### Positive Aspects

- Good use of DPDK macros (`RTE_BIT32`, `RTE_SHIFT_VAL32`, `UINT32_C`)
- Comprehensive test additions using proper test framework
- Clear commit messages explaining the issues and fixes
- Proper patch ordering (dependencies handled correctly)
- License/copyright compliance (no changes needed)
- Code follows DPDK style guidelines


  parent reply	other threads:[~2026-01-23  5:22 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 15:30 [PATCH 0/3] bpf: simple tests and fixes Marat Khalili
2025-11-10 15:30 ` [PATCH 1/3] bpf: fix signed shift overflows in ARM JIT Marat Khalili
2025-11-11  6:25   ` Jerin Jacob
2025-11-11  7:53     ` Morten Brørup
2025-11-11 10:10     ` Marat Khalili
2025-11-11 16:29       ` Jerin Jacob
2025-11-11 16:31       ` Jerin Jacob
2025-11-11 16:39         ` Marat Khalili
2025-11-12  5:23           ` Jerin Jacob
2025-11-12 10:16             ` Marat Khalili
2025-11-10 15:30 ` [PATCH 2/3] bpf: disallow empty program Marat Khalili
2025-11-10 16:40   ` Stephen Hemminger
2025-11-10 16:46     ` Marat Khalili
2025-11-12 15:35   ` Konstantin Ananyev
2025-11-10 15:30 ` [PATCH 3/3] bpf: make add/subtract one program validate Marat Khalili
2025-11-12 15:37   ` Konstantin Ananyev
2025-12-16 18:20 ` [PATCH v2 0/5] bpf: simple tests and fixes Marat Khalili
2025-12-16 18:20   ` [PATCH v2 1/5] eal: variable first arguments of RTE_SHIFT_VALxx Marat Khalili
2025-12-17  9:25     ` Morten Brørup
2025-12-16 18:20   ` [PATCH v2 2/5] bpf: fix signed shift overflows in ARM JIT Marat Khalili
2025-12-17  9:49     ` Morten Brørup
2025-12-16 18:20   ` [PATCH v2 3/5] bpf: disallow empty program Marat Khalili
2025-12-18  0:54     ` Stephen Hemminger
2025-12-17  8:58       ` Marat Khalili
2025-12-16 18:20   ` [PATCH v2 4/5] bpf: make add/subtract one program validate Marat Khalili
2025-12-16 18:20   ` [PATCH v2 5/5] bpf: fix BPF validation w/ conditional jump first Marat Khalili
2025-12-17 18:01   ` [PATCH v3 0/6] bpf: simple tests and fixes Marat Khalili
2025-12-17 18:01     ` [PATCH v3 1/6] eal: variable first arguments of RTE_SHIFT_VALxx Marat Khalili
2025-12-19 13:06       ` Konstantin Ananyev
2025-12-17 18:01     ` [PATCH v3 2/6] bpf: fix signed shift overflows in ARM JIT Marat Khalili
2025-12-19 13:13       ` Konstantin Ananyev
2025-12-17 18:01     ` [PATCH v3 3/6] bpf: mark ARM opcodes with UINT32_C Marat Khalili
2025-12-19 13:14       ` Konstantin Ananyev
2025-12-17 18:01     ` [PATCH v3 4/6] bpf: disallow empty program Marat Khalili
2025-12-17 18:01     ` [PATCH v3 5/6] bpf: make add/subtract one program validate Marat Khalili
2025-12-17 18:01     ` [PATCH v3 6/6] bpf: fix BPF validation w/ conditional jump first Marat Khalili
2026-01-08 11:10       ` Konstantin Ananyev
2026-01-14 19:50     ` [PATCH v3 0/6] bpf: simple tests and fixes Stephen Hemminger
2026-01-23  5:22     ` Stephen Hemminger [this message]
2026-01-27 11:49     ` [PATCH v4 " Marat Khalili
2026-01-27 11:49       ` [PATCH v4 1/6] eal: variable first arguments of RTE_SHIFT_VALxx Marat Khalili
2026-01-28  0:41         ` fengchengwen
2026-01-27 11:49       ` [PATCH v4 2/6] bpf: fix signed shift overflows in ARM JIT Marat Khalili
2026-01-27 11:49       ` [PATCH v4 3/6] bpf: mark ARM opcodes with UINT32_C Marat Khalili
2026-01-27 11:49       ` [PATCH v4 4/6] bpf: disallow empty program Marat Khalili
2026-01-27 11:49       ` [PATCH v4 5/6] bpf: make add/subtract one program validate Marat Khalili
2026-01-27 11:49       ` [PATCH v4 6/6] bpf: fix validation when conditional jump is first instruction Marat Khalili
2026-01-27 14:02       ` [PATCH v4 0/6] bpf: simple tests and fixes Stephen Hemminger
2026-02-04 11:44         ` Thomas Monjalon
2026-02-04 13:33           ` Konstantin Ananyev
2026-02-04 16:58       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260122212240.3ad5344d@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=jerinjacobk@gmail.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=marat.khalili@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox