Skip to content

new: uprobe OverrideCall action#4990

Open
FedeDP wants to merge 8 commits into
mainfrom
fededp/new/uprobe_action_override_call
Open

new: uprobe OverrideCall action#4990
FedeDP wants to merge 8 commits into
mainfrom
fededp/new/uprobe_action_override_call

Conversation

@FedeDP
Copy link
Copy Markdown
Contributor

@FedeDP FedeDP commented May 12, 2026

Description

This PR introduces a new Action for uprobes: OverrideCall. It allows to route the uprobe symbol calls to the specified newSymbol symbol.

uprobes:
- path: "test"
  symbols:
  - "malloc"
  selectors:
  - matchActions:
    - action: OverrideCall
      newSymbol: "malloc_patched"

Shortcomings:

  • the new symbol must be binary-compatible with the hooked one! (no check is in place!)
  • the new symbol must be already present in the binary
  • uprobe only
  • only one uprobe hook symbol/addr/offset is supported when using the new action
  • kernel support to mess with raw regs is needed
  • mixing Override and OverrideCall is unsupported (makes no sense anyway); but the code to support it is there, the mixing only gets gated behind a conditional check

Changelog

new: uprobe OverrideCall action

@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 709198c
🔍 Latest deploy log https://app.netlify.com/projects/tetragon/deploys/6a02fce99edaee0008a5848f
😎 Deploy Preview https://deploy-preview-4990--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

FedeDP added 4 commits May 12, 2026 12:07
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Also, update `hasEnforcementActions` with the new `HasOverrideCall`.
Check only for uprobes since `OverrideCall` is only supported for them.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
We treat OverrideCall just like a specific case of Override action.
We are just going to override the instruction pointer register
with the address of the desired function, after all.

Following the above, ebpf `regs_map` was expanded to 2 elements:
* [0] is for ActionTypeOverride registers
* [1] is for ActionTypeOverrideCall registers

Basically, we compute the correct address we need to jump to by:
* computing the diff between real symbol being called and new symbol to be called
* intrument the intruction pointer register as an `ASM_ASSIGNMENT_TYPE_REG_OFF`

This way, we ask the uprobe code to jump from current instruction ptr (that is at entry of
symbol being traced) to instruction ptr + diff(real symbol, new symbol) and we reach new symbol.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@FedeDP FedeDP force-pushed the fededp/new/uprobe_action_override_call branch 2 times, most recently from 38275dc to 709198c Compare May 12, 2026 10:11
FedeDP added 4 commits May 12, 2026 12:14
As we've seen in the userspace commit, OverrideCall action
is treated exactly like an override.
Remember that we need to avoid `write_reg` outside of offload context,
or verifier will fail.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@FedeDP FedeDP force-pushed the fededp/new/uprobe_action_override_call branch from 709198c to 5a3fa99 Compare May 12, 2026 10:14
@FedeDP FedeDP added release-note/minor This PR introduces a minor user-visible change kind/feature This introduces a new functionality labels May 12, 2026
@mtardy
Copy link
Copy Markdown
Member

mtardy commented May 12, 2026

Might be worth chatting with @dwindsor about the "override" API also used from #4817.

@FedeDP
Copy link
Copy Markdown
Contributor Author

FedeDP commented May 12, 2026

Thanks @mtardy for the pointer, didn't notice that PR had a new Override sub-action (clearGoString).
Will chat with David for sure!

@FedeDP FedeDP marked this pull request as ready for review May 12, 2026 12:00
@FedeDP FedeDP requested review from a team and mtardy as code owners May 12, 2026 12:00
@FedeDP FedeDP requested a review from kkourt May 12, 2026 14:17
@dwindsor
Copy link
Copy Markdown
Contributor

Not sure what this PR is doing but the overall shape of the clearGoString override is:

- matchActions:
 - action: Override
    argIndex: 2
    clearGoString: true

@dwindsor
Copy link
Copy Markdown
Contributor

dwindsor commented May 12, 2026

Interesting! A few comments.

  1. What runtimes are we supporting with this? Seems like symtab would still be necessary to make this work.

  2. the new symbol must be already present in the binary

Does this mean a security team needs to pre-compile and seed the binary?

  1. Some of the assumptions regarding target function address calculation andPT_LOAD will break down unless it's statically-compiled Go. Offset() in file.go finds the first PT_LOAD segment containing the vaddr and uses this as the base. This assumption won't hold across all runtimes / linkers, for instance when creating shared libraries if multiple PT_LOAD segments are created, a vaddr in one could easily collide with a vaddr in another. If the symbol we're replacing (malloc) is in a different segment than the symbol we're replacing it with (malloc_patched), the replacement works. But if it's in another segment, the RIP calculation will silently fail.

@FedeDP
Copy link
Copy Markdown
Contributor Author

FedeDP commented May 12, 2026

What runtimes are we supporting with this? Seems like symtab would still be necessary to make this work.

Yes, exactly. In case the binary is going to be stripped, one can provide directly the Offset.

Does this mean a security team needs to pre-compile and seed the binary?

Yes; this is mostly an initial feature set, of course. We can expand it later!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature This introduces a new functionality release-note/minor This PR introduces a minor user-visible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants