NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/55780: setsockopt in Linux emulation misses some options



>Number:         55780
>Category:       kern
>Synopsis:       setsockopt in Linux emulation misses some options
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 03 19:40:00 +0000 2020
>Originator:     bernd.sieker%posteo.net@localhost
>Release:        NetBSD 9.1
>Organization:
>Environment:
System: NetBSD niob.bersie.loc 9.1 NetBSD 9.1 (NIOB) #25: Fri Oct 16 18:27:33 CEST 2020 bernd%niob.bersie.loc@localhost:/usr/src/sys/arch/amd64/compile/NIOB amd64
Architecture: x86_64
Machine: amd64
>Description:
When Linux programs running under the Linux emulation try to set certain socket options (such as receive timeout), the call fails, causing limited functionality of the Linux program, even though NetBSD implements the option.

It turns out that linux_socket.c misses a few cases of SO options in linux_to_bsd_so_sockopt, notably LINUX_SO_RCVTIMEO and SO_RCVTIMEO, returning EINVAL to the calling Linux program, causing some problems, e. g. with the folding-at-home client.

Several further options may also be missing, but RCVTIMEO was the one I noticed. linux_socket_generic.h defines many more than linux_to_bsd_so_sockopt is mapping. I guess the code just hasn't been touched in a long time.

>How-To-Repeat:
Run a Linux program which tries to set socket receive timeout in NetBSD's Linux emulation, e. g. Folding at Home Client 7.6.21.
>Fix:
Apply the following patch, recompile the kernel and reboot:

--- sys/compat/linux/common/linux_socket.c.orig 2020-11-03 17:27:47.055555944 +0100
+++ sys/compat/linux/common/linux_socket.c      2020-11-03 18:28:20.184244766 +0100
@@ -884,6 +884,10 @@
                return SO_SNDLOWAT;
        case LINUX_SO_RCVLOWAT:
                return SO_RCVLOWAT;
+       case LINUX_SO_RCVTIMEO:
+               return SO_RCVTIMEO;
+       case LINUX_SO_SNDTIMEO:
+               return SO_SNDTIMEO;
        case LINUX_SO_KEEPALIVE:
                return SO_KEEPALIVE;
        case LINUX_SO_OOBINLINE:



Home | Main Index | Thread Index | Old Index