net: abort SO_DEVMEM_DONTNEED sooner

In case user provided wrong input, SO_DEVMEM_DONTNEED could
spin many times (2^32 or more) and lock cpu for many seconds.

Abort the loop immediately in case of an error.

Note the ABI does not report back number of pages that have
been released anyway, so tcpdirect never expected a failure there.

Test the unlikely() case first, to reduce indentation level
of the fast path.

cos-patch: bug
Fixes: ac4a2b0ef821 ("PRODKERNEL: net-tcpdirect-fastrak: add SO_DEVMEM_DONTNEED setsockopt to release pages")
Tested: Ran syzbot repro
Reported-and-tested-by: [email protected]
Effort: net-tcpdirect-fastrak
Upstream-Plan: 232518966
Google-Bug-Id: 325732619
Signed-off-by: Eric Dumazet <[email protected]>
Change-Id: I4c64ec56bd0ea65d030a9e817e64517dc01333a6
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/65370
Reviewed-by: Mina Almasry <[email protected]>
Tested-by: Minh-Anh Nguyen <[email protected]>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/65431
Reviewed-by: Oleksandr Tymoshenko <[email protected]>
Tested-by: Cusky Presubmit Bot <[email protected]>
Main-Branch-Verified: Cusky Presubmit Bot <[email protected]>
1 file changed