|
|
Subscribe / Log in / New account

Bounded loops in BPF programs

Bounded loops in BPF programs

Posted Dec 4, 2018 8:45 UTC (Tue) by mjthayer (guest, #39183)
In reply to: Bounded loops in BPF programs by Cyberax
Parent article: Bounded loops in BPF programs

> It would be possible. The BPF compiler will need to add the timeout checks before each backwards jump but somehow I doubt the kernel developers want this.

I was more thinking of something in the execution engine.


to post comments

Bounded loops in BPF programs

Posted Dec 4, 2018 9:27 UTC (Tue) by Sesse (subscriber, #53779) [Link]

There is no execution engine in modern eBPF; it's statically compiled to machine code.

Bounded loops in BPF programs

Posted Dec 4, 2018 9:33 UTC (Tue) by roc (subscriber, #30627) [Link] (3 responses)

BPF is JITted these days so there is no boundary between the compiler and execution engine.

Bounded loops in BPF programs

Posted Dec 4, 2018 10:33 UTC (Tue) by sdalley (subscriber, #18550) [Link] (2 responses)

So, there's no identifiable thread or task doing the BPF that could be watchdogged ?

Bounded loops in BPF programs

Posted Dec 4, 2018 10:48 UTC (Tue) by corbet (editor, #1) [Link] (1 responses)

There is no separate thread, no. One could always set a timer to bring an end to runaway execution, but that would be an expensive thing to do.

Bounded loops in BPF programs

Posted Dec 4, 2018 18:43 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

You can keep track of "remaining instructions" in a register that is decremented on every backwards jump by the number of instructions in the jump. Then just compare it with zero.

The comparison will be branch-predicted most of the time and will be fast.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds