From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Mon, 10 Oct 2016 12:05:17 -0700
David - I think that also explains what was wrong with the old code.
In the old code, this loop:
while (hooks_entry && nf_entry_dereference(hooks_entry->next)) {
would exit with "hooks_entry" pointing to the last list entry (because
->next was NULL). Nothing was ever unlinked in the loop itself,
because it never actually found a matching entry, but then after the
loop it would free that last entry because it *thought* that was the
match.
It only does this when the ops don't match, but yes it can happen.
Linus can you add some extra info to that:
WARN(1, "nf_unregister_net_hook: hook not found!\n");
diagnostic, such as the reg->pf and reg->hooknum values?
That might help track down why this is happening in the first
place.