xt_check_entry_offsets(9)
π
xt_check_entry_offsets(9) β Kernel API Manual, but make it make sense π
Hiii bestie, welcome to xt_check_entry_offsets(9) from the Kernel API Manual. This is the little validity-checker function for arp/ip/ip6t_entry, and yes, it is lowkey doing important gatekeeping work. π«Ά
πΈ NAME πΈ
xt_check_entry_offsets β validate arp/ip/ip6t_entry
β¨ SYNOPSIS β¨
int xt_check_entry_offsets (const void *base , const char *elems ,
unsigned int target_offset , unsigned int next_offset );
π ARGUMENTS π
baseβ pointer toarp/ip/ip6t_entry. This is the entry bestie in question. πelemsβ pointer to the firstxt_entry_match, i.e.ip(6)t_entry->elems. Itβs where the match structures start showing up. β¨target_offsetβ thearp/ip/ip6_t->target_offset. Yes, exactly that one.next_offsetβ thearp/ip/ip6_t->next_offset. Also exactly that one. No cap. π―
π¦ DESCRIPTION π¦
Okay so what this function does is validate that target_offset and next_offset are sane, and that all match sizes (if any) align with the target offset. Itβs giving βmake sure the offsets arenβt cursedβ energy. π
This function does not validate the targets or matches themselves, bestie. It only tests that all the offsets and sizes are correct, that all match structures are aligned, and that the last structure ends where the target structure begins. Periodt. π
Also, peep xt_compat_check_entry_offsets for the CONFIG_NETFILTER_XTABLES_COMPAT version. iykyk. π
The arp/ip/ip6t_entry structure base must have passed following tests:
- it must point to a valid memory location
basetobase + next_offsetmust be accessible, i.e. not exceed allocated length.
β οΈ Bestie, those two checks are non-negotiable.basehas to be real and the wholebaseβbase + next_offsetrange has to be accessible, not past the allocated length. π«Ά
A well-formed entry looks like this:
ip(6)t_entry match [mtdata] match [mtdata] target [tgdata]
ip(6)t_entry e->elems[]-----' |
| matchsize | | matchsize |
| | | target_offset---------------------------------'
| next_offset---------------------------------------------------'
elems[]: flexible array member at end of ip(6)/arpt_entry struct. This is where matches (if any) and the target reside. target_offset: beginning of target. next_offset: start of the next rule; also: size of this rule. Since targets have a minimum size, target_offset + minlen <= next_offset. π
Every match stores its size, sum of sizes must not exceed target_offset. That part is literally the vibe check for match sizes. β¨
π RETURN π
0 on success, negative errno on failure. Slay when itβs zero, cry a little when itβs negative. π
π₯ SEE ALSO π₯
Kernel file ./net/netfilter/x_tables.c β plus the whole related crew:
xt_check_proc_name(9)xt_alloc_entry_offsets(9)xt_find_jump_offset(9)xt_copy_counters(9)xt_unregister_table_pre_exit(9)xt_unregister_table_exit(9)xt_hook_ops_alloc(9)xt_percpu_counter_alloc(9)
And thatβs the page, bestie. The footer/source energy is ./net/netfilter, and the date stamp is October 2026. Bye-bye, go validate those offsets responsibly. πβ¨ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms