Skip to content

fix(ebpf): correct logical operator bugs in protocol_inference.h#11510

Open
kalakotima wants to merge 2 commits intodeepflowio:mainfrom
kalakotima:protocol-port-MK
Open

fix(ebpf): correct logical operator bugs in protocol_inference.h#11510
kalakotima wants to merge 2 commits intodeepflowio:mainfrom
kalakotima:protocol-port-MK

Conversation

@kalakotima
Copy link

Summary

This PR fixes multiple critical logical operator bugs in
agent/src/ebpf/kernel/include/protocol_inference.h that affect
protocol identification for HTTP/1.x, PostgreSQL, ISO8583, Redis,
and NATS protocols.

Root Cause

Several functions contained two categories of operator errors:

These errors cause silent logic failures — the eBPF program loads
and runs but produces "wrong protocol inference results" at runtime.

The following bugs were identified and fixed:

  1. __protocol_port_check(): comma operator ',' used instead of '||'
    in the L7_PROTO_INFER_PROG_1 branch, causing the first
    is_set_bitmap() result to be silently discarded, leading to
    incorrect port-based protocol filtering.

  2. is_http_request(): array close bracket ']' used instead of '||'
    combined with proper array indexing 'data[N]' across all HTTP
    method checks (DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT),
    breaking all multi-character method validation.

  3. infer_pgsql_startup_message(): array close bracket ']' used
    instead of '||' in the "user" string validation check for
    buf[8..11], breaking PostgreSQL startup message detection.

  4. infer_iso8583_message(): array close bracket ']' used instead
    of '||' in CUPS header flag checks and buffer content validation,
    breaking ISO8583 protocol identification entirely.

  5. infer_redis_message(): array close bracket ']' used instead of
    '||' in the error prefix validation (buf[2] check), causing
    valid Redis error responses to be incorrectly dropped.

  6. infer_nats_message(): array close bracket ']' used instead of
    '||' in the CRLF terminator check, causing all NATS protocol
    messages to be rejected during initial socket inference.

These bugs collectively affect HTTP/1.x, PostgreSQL, ISO8583, Redis,
and NATS protocol inference, causing silent misidentification or
complete failure to detect these protocols in production environments.

Signed-off-by: kalakotima@gmail.com <manojreddy@Manojs-MacBook-Air.local>
@CLAassistant
Copy link

CLAassistant commented Mar 25, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ kalakotima
kalakotima@gmail.com


kalakotima@gmail.com seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Signed-off-by: kalakotima@gmail.com <manojreddy@Manojs-MacBook-Air.local>
Signed-off-by: kalakotima@gmail.com <kalakotima@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants