Repository navigation
Conversation
A function with a jump past the 16-bit off of struct bpf_insn, -32768 to 32767 instructions, ended the compile in code:pack, whose string.pack raised "insn.lua:315: bad argument #4 to 'pack' (integer overflow)", naming the compiler's file and no line of the program file. Each check that may stop takes a block of 31 instructions after the tail, so one function of 1057 reads of the packet compiles to 51811 instructions, and the last block's jump back to the tail spans 32769. Such a function is now refused at the line it is defined at, the program's or a callee's: lunatik: far.bpf.lua:3: the function compiles to 51811 instructions, and a jump in it spans more than the 32767 a jump reaches The refusal reads the jumps of the code the settled walk leaves, code:reaches, which resolves each off as pack does: a count of instructions alone would refuse functions that compile today, 1000 reads in 49018 instructions and 40000 additions before one read in 160067, whose jumps all fit. The program files of Lunatik's tests compile to the same objects, byte for byte. The long jump, BPF_JMP32 | BPF_JA, lifts nothing across the range: it has no conditional form, so a far conditional becomes a near one over a gotol, which moves every later position, and the JITs of x86-32, riscv32, mips, sparc64 and parisc take none as of v6.18, where the load then fails under CONFIG_BPF_JIT_ALWAYS_ON or for a program that calls a kfunc. LLVM refuses the same way below cpu v4, "Branch target out of insn range" (BPFAsmBackend.cpp). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A program file whose function is too long for an eBPF jump fails to compile with an error of the compiler's own file,
insn.lua:315: bad argument #4 to 'pack' (integer overflow), which names no line of the program file and says nothing of its size.Such a function is now refused as every other refusal of
lunatik bpfreads,lunatik: <file>:<line>: <message>, at the line the function is defined at, with how many instructions it compiles to and how far a jump reaches:The refusal reads the jumps and not the size, so a function whose jumps all fit compiles as it does today, to the same object, however long it is. The guide lists the message, and the way out: part of the function moved to a function it calls, which is compiled apart, with jumps of its own. A callee too long is refused at its own line.
Nothing is lifted: the long jump,
gotol, has no conditional form and not every JIT of the kernels Lunatik supports takes it, so the limit stays and is named. The tests are in Lunatik'stests/luaebpf/refuse.shand come with the Lunatik pull request that updates itsluaebpf/submodule to this change and closes luaebpf#4. This one answers luaebpf#4, which it does not close.