linux(4): Add a helper to copyout getsockopt value
For getsockopt(), optlen is a value-result argument, which is modified
on return to indicate the actual size of the value returned.
For some cases this was missed, fixed.
MFC after: 2 weeks
(cherry picked from commit e92b9a9eaa646bc1037af2a838270c43ea607d55)