Skip to content

fix: correlate read events per thread - #29

Open
st4ckrift wants to merge 1 commit into
sshlog:masterfrom
st4ckrift:fix/session-logs-stopping
Open

st4ckrift wants to merge 1 commit into
sshlog:masterfrom
st4ckrift:fix/session-logs-stopping

Conversation

@st4ckrift

Copy link
Copy Markdown

Problem

Read-event correlation used the parent TGID as the key for connections_read_mapping. Multiple threads belonging to the same process could overwrite each other's pending read mappings.

Additionally, stale mappings could remain when sys_exit_read returned early due to rate limiting, missing connections, or event allocation failures.

Changes

  • Changed connections_read_mapping keys from u32 to u64.
  • Use bpf_get_current_pid_tgid() in both sys_enter_read and sys_exit_read for per-thread syscall correlation.
  • Preserve parent_tgid for connection lookup and event metadata.
  • Copy the mapping value locally and delete the map entry immediately in sys_exit_read, ensuring cleanup before subsequent early returns.

Validation

  • BPF object and skeleton generation succeeded.
  • sshlog_cli built successfully.
  • git diff --check passed.
  • Runtime testing with live SSH sessions has not yet been performed.

Resolves #28

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.

Session logs stop working after a few minutes

1 participant