xt_check_entry_offsets(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 to arp/ip/ip6t_entry. This is the entry bestie in question. πŸ’–
  • elems β€” pointer to the first xt_entry_match, i.e. ip(6)t_entry->elems. It’s where the match structures start showing up. ✨
  • target_offset β€” the arp/ip/ip6_t->target_offset. Yes, exactly that one.
  • next_offset β€” the arp/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
  • base to base + next_offset must be accessible, i.e. not exceed allocated length.
⚠️ Bestie, those two checks are non-negotiable. base has to be real and the whole base β†’ base + next_offset range 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:


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