hackerschoice / gsocket

Connect like there is no firewall. Securely.
https://www.gsocket.io
BSD 2-Clause "Simplified" License
1.53k stars 129 forks source link

rare select loop around not-tracked fd #40

Closed rootTHC closed 3 years ago

rootTHC commented 3 years ago

gsocket starts sshd on server.

server: gsocket /usr/sbin/sshd

noticed gs-netcat consuming 100% cpu load on a 16-core system which was under heavy load. Select() call seems to track fd=3 but app never reads from it:

select(9, [0 3 5 7 8], [], NULL, {tv_sec=0, tv_usec=603003}) = 1 (in [3], left {tv_sec=0, tv_usec=603002})                                          
select(9, [0 3 5 7 8], [], NULL, {tv_sec=0, tv_usec=602988}) = 1 (in [3], left {tv_sec=0, tv_usec=602987})                                          
select(9, [0 3 5 7 8], [], NULL, {tv_sec=0, tv_usec=602972}) = 1 (in [3], left {tv_sec=0, tv_usec=602971})                                          
select(9, [0 3 5 7 8], [], NULL, {tv_sec=0, tv_usec=602956}) = 2 (in [3 7], left {tv_sec=0, tv_usec=602955})                                        
read(7, "\27\3\3\0T", 5)                = 5                                                                                                         
read(7, "\1\16z\334}\310sh\7k\241\324uE\22024\323;R\326_]\274\211\3375;O\326N\260"..., 84) = 84                                                     
write(8, "-\256\315-\371%\331\275\302\312\223\231\202\23o\237Z)K\350($\3663\221\330o\312\316M-\5"..., 36) = 36                                                                                                                                                                                           
select(9, [0 3 5 7 8], [], NULL, {tv_sec=0, tv_usec=602862}) = 2 (in [3 7], left {tv_sec=0, tv_usec=602861})                                        
read(7, "\27\3\3\0T", 5)                = 5                                                                                                         
read(7, "\21\314\317dX0\201B5G\21'\314\221\270\210\337\30\201B-C\210\32\24\213\322N\n\303\370\34"..., 84) = 84                                      
write(8, "\222\347>F\272Th?\353\31\303\211\264\364\30\360G2\254\272\337\342\364\242'\350\217izM`("..., 36) = 36                                     
select(9, [0 3 5 7 8], [], NULL, {tv_sec=0, tv_usec=602790}) = 3 (in [3 7 8], left {tv_sec=0, tv_usec=602789})                                      
read(7, "\27\3\3\0T", 5)                = 5                                                                                                         
read(7, "\224\267\300\227\345\0322\242\334aY\216H\f\246\364q=\356\276\327\3016N_q\333\n^\10\211Z"..., 84) = 84                                      
write(8, "\352;\33\202\v(m\2110~\223\367>\267k\215\301\244\376\317\323\27\200\346\270\254\320\337\267\\\253\303"..., 36

FD 0 is the watchdog stdin monitor FD 5 must be the next GSRN listening connection FD 7 is the GS connection (active) FD 8 is the localhost forward (to sshd)

FD 3 could be the old forward or an old GS connection.

Bug ideas:

This bug could not be re-prodcued.

rootTHC commented 3 years ago

fixed in 1.4.30.