In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix bpfskselect_reuseport() memory leak
As pointed out in the original comment, lookup in sockmap can return a TCP ESTABLISHED socket. Such TCP socket may have had SOATTACHREUSEPORTEBPF set before it was ESTABLISHED. In other words, a non-NULL skreuseport_cb does not imply a non-refcounted socket.
Drop sk's reference in both error paths.
unreferenced object 0xffff888101911800 (size 2048): comm "testprogs", pid 44109, jiffies 4297131437 hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 80 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc 9336483b): _kmallocnoprof+0x3bf/0x560 _reuseportalloc+0x1d/0x40 reuseportalloc+0xca/0x150 reuseportattachprog+0x87/0x140 skreuseportattachbpf+0xc8/0x100 sksetsockopt+0x1181/0x1990 dosocksetsockopt+0x12b/0x160 _syssetsockopt+0x7b/0xc0 _x64syssetsockopt+0x1b/0x30 dosyscall64+0x93/0x180 entrySYSCALL64after_hwframe+0x76/0x7e