inet: frags: fix a race between inet_evict_bucket and inet_frag_kill
inet: frags: fix a race between inet_evict_bucket and inet_frag_kill

When the evictor is running it adds some chosen frags to a local list to
be evicted once the chain lock has been released but at the same time
the *frag_queue can be running for some of the same queues and it
may call inet_frag_kill which will wait on the chain lock and
will then delete the queue from the wrong list since it was added in the
eviction one. The fix is simple - check if the queue has the evict flag
set under the chain lock before deleting it, this is safe because the
evict flag is set only under that lock and having the flag set also means
that the queue has been detached from the chain list, so no need to delete
it again.
An important note to make is that we're safe w.r.t refcnt because
inet_frag_kill and inet_evict_bucket will sync on the del_timer operation
where only one of the two can succeed (or if the timer is executing -
none of them), the cases are:
1. inet_frag_kill succeeds in del_timer
 - then the timer ref is removed, but inet_evict_bucket will not add
   this queue to its expire list but will restart eviction in that chain
2. inet_evict_bucket succeeds in del_timer
 - then the timer ref is kept until the evictor "expires" the queue, but
   inet_frag_kill will remove the initial ref and will set
   INET_FRAG_COMPLETE which will make the frag_expire fn just to remove
   its ref.
In the end all of the queue users will do an inet_frag_put and the one
that reaches 0 will free it. The refcount balance should be okay.

CC: Florian Westphal <cef439e78636cdab99cd2923826c5065a0743e5b@strlen.de>
CC: Eric Dumazet <a0baddf32b28d2f9429941ed4af2fe636e210591@gmail.com>
CC: Patrick McLean <57bb92fad5dd6826be3031d887a5397b8cff9e8f@gentoo.org>

Fixes: b13d3cbfb8e8 ("inet: frag: move eviction of queues to work queue")
Suggested-by: Eric Dumazet <a0baddf32b28d2f9429941ed4af2fe636e210591@gmail.com>
Reported-by: Patrick McLean <57bb92fad5dd6826be3031d887a5397b8cff9e8f@gentoo.org>
Tested-by: Patrick McLean <57bb92fad5dd6826be3031d887a5397b8cff9e8f@gentoo.org>
Signed-off-by: Nikolay Aleksandrov <262b42b771725e3ebec40395f2b058e593df7462@redhat.com>
Reviewed-by: Florian Westphal <cef439e78636cdab99cd2923826c5065a0743e5b@strlen.de>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs