NetBSD Problem Report #53103

From www@NetBSD.org  Fri Mar 16 15:37:30 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 542C07A174
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 16 Mar 2018 15:37:30 +0000 (UTC)
Message-Id: <20180316153728.EBE647A218@mollari.NetBSD.org>
Date: Fri, 16 Mar 2018 15:37:28 +0000 (UTC)
From: van.fstd@gmail.com
Reply-To: van.fstd@gmail.com
To: gnats-bugs@NetBSD.org
Subject: linux emulation of sendto(2) broken (testcase included)
X-Send-Pr-Version: www-1.0

>Number:         53103
>Category:       lib
>Synopsis:       linux emulation of sendto(2) broken (testcase included)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 16 15:40:00 +0000 2018
>Closed-Date:    Mon Jun 04 10:30:38 +0000 2018
>Last-Modified:  Sat Dec 08 12:25:00 +0000 2018
>Originator:     Timo Buhrmester
>Release:        8.0_BETA
>Organization:
>Environment:
NetBSD kiwi.pr0.tips 8.0_BETA NetBSD 8.0_BETA (KIWIKERN) #0: Fri Mar 16 01:29:50 CET 2018  build@kiwi.pr0.tips:/stor/netbsd/obj/sys/arch/amd64/compile/KIWIKERN amd64
>Description:
linux-emulated sendto(2) fails with EFAULT in a situation where the native sendto(2) succeeds.

Ultimate failure is in 'copyin', got there via
sockargs via
do_sys_sendmsg_so via
do_sys_sendmsg from
linux_sys_sendto

Testcase below
>How-To-Repeat:
The below program takes two arguments, an IP address and a port number, and sends a UDP datagram containing "hello world\n" to said address/port using sendto(2)

Compile it on a 64bit Linux machine (Debian 9 in my case) 
and try to run it under NetBSD's Linux emulation, sendto(2) will fail.
Compile on NetBSD and run natively, it succeeds.


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <unistd.h>

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>

#define MSG "hello world\n"

int
main(int argc, char **argv)
{
        if (argc != 3) {
                fprintf(stderr, "Usage: %s <ip4addr> <port>\n", argv[0]);
                exit(1);
        }

        struct sockaddr_storage ss;
        struct sockaddr_in *sa = (struct sockaddr_in *)&ss;

        struct in_addr ia;
        int r = inet_pton(AF_INET, argv[1], &ia);
        if (r != 1) {
                perror("inet_pton");
                exit(1);
        }

        sa->sin_family = AF_INET;
        sa->sin_addr = ia;
        sa->sin_port = htons(atoi(argv[2]));

        int s = socket(AF_INET, SOCK_DGRAM, 0);

        ssize_t st = sendto(s, MSG, strlen(MSG), 0, (struct sockaddr *)sa, sizeof *sa);
        fprintf(stderr, "sendto: returned %zd, expected %zu\n", st, strlen(MSG));
}

>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53103 CVS commit: src/sys
Date: Fri, 16 Mar 2018 13:25:04 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Fri Mar 16 17:25:04 UTC 2018

 Modified Files:
 	src/sys/compat/common: uipc_syscalls_43.c
 	src/sys/compat/linux/common: linux_socket.c
 	src/sys/compat/netbsd32: netbsd32_compat_43.c
 	src/sys/kern: uipc_syscalls.c
 	src/sys/nfs: nfs_syscalls.c nfs_vfsops.c
 	src/sys/sys: param.h socketvar.h

 Log Message:
 PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

 The sockargs refactoring broke it, because sockargs only works with a user
 address. Added an argument to sockargs to indicate where the address is
 coming from. Welcome to 8.99.14.


 To generate a diff of this commit:
 cvs rdiff -u -r1.47 -r1.48 src/sys/compat/common/uipc_syscalls_43.c
 cvs rdiff -u -r1.139 -r1.140 src/sys/compat/linux/common/linux_socket.c
 cvs rdiff -u -r1.54 -r1.55 src/sys/compat/netbsd32/netbsd32_compat_43.c
 cvs rdiff -u -r1.191 -r1.192 src/sys/kern/uipc_syscalls.c
 cvs rdiff -u -r1.159 -r1.160 src/sys/nfs/nfs_syscalls.c
 cvs rdiff -u -r1.235 -r1.236 src/sys/nfs/nfs_vfsops.c
 cvs rdiff -u -r1.558 -r1.559 src/sys/sys/param.h
 cvs rdiff -u -r1.146 -r1.147 src/sys/sys/socketvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Mon, 04 Jun 2018 08:59:45 +0000
State-Changed-Why:
Does it work correctly now?


From: van.fstd@gmail.com
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/53103 (linux emulation of sendto(2) broken (testcase
 included))
Date: Mon, 4 Jun 2018 11:29:40 +0200

 > Does it work correctly now?
 It does, thanks again!

State-Changed-From-To: feedback->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Mon, 04 Jun 2018 10:30:38 +0000
State-Changed-Why:
Feedback positive. Thanks for the report, thanks xtos for the fix


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org, christos@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: PR/53103 CVS commit: src/sys
Date: Mon, 24 Sep 2018 10:45:52 +0900

 > Subject: PR/53103 CVS commit: src/sys
 > Date: Fri, 16 Mar 2018 13:25:04 -0400
 > 
 >  Module Name:	src
 >  Committed By:	christos
 >  Date:		Fri Mar 16 17:25:04 UTC 2018
 >  
 >  Modified Files:
 >  	src/sys/compat/common: uipc_syscalls_43.c
 >  	src/sys/compat/linux/common: linux_socket.c
 >  	src/sys/compat/netbsd32: netbsd32_compat_43.c
 >  	src/sys/kern: uipc_syscalls.c
 >  	src/sys/nfs: nfs_syscalls.c nfs_vfsops.c
 >  	src/sys/sys: param.h socketvar.h
 >  
 >  Log Message:
 >  PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken
 >  
 >  The sockargs refactoring broke it, because sockargs only works with a user
 >  address. Added an argument to sockargs to indicate where the address is
 >  coming from. Welcome to 8.99.14.

 At Open Source Conference 2018 Hiroshima, there is a report
 (from HIROSE yuuji at Tohoku University of Community Service and Science,
  who largely use NetBSD/amd64 in their curriculum and educations)
 that linux binaries fail to get NIS info, then libreoffice5-bin is
 not usable on NetBSD/amd64 8.0 client environments.

 It looks caused by this PR/53103 and the NetBSD 8.0 release
 (and the netbsd-8 branch) is still affected.

 I can also reproduce it on NetBSD/amd64 8.0 and NetBSD/i386 8.0:
 ---
 (setup ypserver by ypinit(8) on the other host)
  :
 (setup /etc/master.passwd etc to pull NIS info on the client)
  :
 # domainname ypname
 # rpcbind
 # ypbind
  : 
 # pkg_add suse_base-13.1
  :
 % ktrace /usr/pkg/emul/linux/bin/bash
 do_ypcall: clnt_call: RPC: Unable to send; errno = Bad address
 do_ypcall: clnt_call: RPC: Unable to send; errno = Bad address
 bash-4.2$ 
 ---

   7829   7829 bash     CALL  sendto(5,0x6afd1c,0x4c,0,0x6ada28,0x10)
   7829   7829 bash     MISC  mbsoname: [192.168.20.1]
   7829   7829 bash     MISC  msghdr: [name=0xffff80008b99ee78, namelen=16, iov=0xffff80008b99ee38, iovlen=1, control=0x0, controllen=1, flags=0]
   7829   7829 bash     RET   sendto -1 errno -14 Bad address
   7829   7829 bash     CALL  fstat64(2,0x7f7fffffdbd0)
   7829   7829 bash     RET   fstat64 0
   7829   7829 bash     CALL  ioctl(2,_IO('T',0x1,0),0x7f7fffffdb40)
   7829   7829 bash     RET   ioctl 0
   7829   7829 bash     CALL  mmap(0,0x1000,PROT_READ|PROT_WRITE,0x22<PRIVATE,RENAME,FILE,ALIGN=NONE>,0xffffffff,0)
   7829   7829 bash     RET   mmap 140187597262848/0x7f7ff7efd000
   7829   7829 bash     CALL  write(2,0x7f7ff7efd000,0x3f)
   7829   7829 bash     GIO   fd 2 wrote 63 bytes
        "do_ypcall: clnt_call: RPC: Unable to send; errno = Bad address\n"

 ---

 On NetBSD/amd64 7.2 it works without problem:

 ---
    201    201 bash     CALL  sendto(5,0x6b0b9c,0x4c,0,0x6ae8a8,0x10)
    201    201 bash     MISC  linux/sockaddr: 16, 020002fbc0a814010000000000000000
    201    201 bash     MISC  mbsoname: [192.168.20.1]
    201    201 bash     MISC  msghdr: [name=0xfffffe81b108a800, namelen=16, iov=0xfffffe81003dfe48, iovlen=1, control=0x0, controllen=2164428672, flags=1000000]
    201    201 bash     GIO   fd 5 wrote 76 bytes
 ---

 Applying changes in your commit to netbsd-8 also fixes the problem.
 However it requires bump of the kernel revision (i.e. module ABI change)
 as the log message said.

 Is there any proper way to also fix this in the netbsd-8 branch,
 for major users who need to run linux binaries with NIS?

 Thanks,

 ---
 Izumi Tsutsui

From: christos@zoulas.com (Christos Zoulas)
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, gnats-bugs@NetBSD.org
Cc: pullup-8@netbsd.org
Subject: Re: PR/53103 CVS commit: src/sys
Date: Sun, 23 Sep 2018 21:59:06 -0400

 On Sep 24, 10:45am, tsutsui@ceres.dti.ne.jp (Izumi Tsutsui) wrote:
 -- Subject: Re: PR/53103 CVS commit: src/sys

 | > Subject: PR/53103 CVS commit: src/sys
 | > Date: Fri, 16 Mar 2018 13:25:04 -0400
 | > 
 | >  Module Name:	src
 | >  Committed By:	christos
 | >  Date:		Fri Mar 16 17:25:04 UTC 2018
 | >  
 | >  Modified Files:
 | >  	src/sys/compat/common: uipc_syscalls_43.c
 | >  	src/sys/compat/linux/common: linux_socket.c
 | >  	src/sys/compat/netbsd32: netbsd32_compat_43.c
 | >  	src/sys/kern: uipc_syscalls.c
 | >  	src/sys/nfs: nfs_syscalls.c nfs_vfsops.c
 | >  	src/sys/sys: param.h socketvar.h
 | >  
 | >  Log Message:
 | >  PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken
 | >  
 | >  The sockargs refactoring broke it, because sockargs only works with a user
 | >  address. Added an argument to sockargs to indicate where the address is
 | >  coming from. Welcome to 8.99.14.
 | 
 | At Open Source Conference 2018 Hiroshima, there is a report
 | (from HIROSE yuuji at Tohoku University of Community Service and Science,
 |  who largely use NetBSD/amd64 in their curriculum and educations)
 | that linux binaries fail to get NIS info, then libreoffice5-bin is
 | not usable on NetBSD/amd64 8.0 client environments.
 | 
 | It looks caused by this PR/53103 and the NetBSD 8.0 release
 | (and the netbsd-8 branch) is still affected.
 | 
 | I can also reproduce it on NetBSD/amd64 8.0 and NetBSD/i386 8.0:
 | ---
 | (setup ypserver by ypinit(8) on the other host)
 |  :
 | (setup /etc/master.passwd etc to pull NIS info on the client)
 |  :
 | # domainname ypname
 | # rpcbind
 | # ypbind
 |  : 
 | # pkg_add suse_base-13.1
 |  :
 | % ktrace /usr/pkg/emul/linux/bin/bash
 | do_ypcall: clnt_call: RPC: Unable to send; errno = Bad address
 | do_ypcall: clnt_call: RPC: Unable to send; errno = Bad address
 | bash-4.2$ 
 | ---
 | 
 |   7829   7829 bash     CALL  sendto(5,0x6afd1c,0x4c,0,0x6ada28,0x10)
 |   7829   7829 bash     MISC  mbsoname: [192.168.20.1]
 |   7829   7829 bash     MISC  msghdr: [name=0xffff80008b99ee78, namelen=16, iov=0xffff80008b99ee38, iovlen=1, control=0x0, controllen=1, flags=0]
 |   7829   7829 bash     RET   sendto -1 errno -14 Bad address
 |   7829   7829 bash     CALL  fstat64(2,0x7f7fffffdbd0)
 |   7829   7829 bash     RET   fstat64 0
 |   7829   7829 bash     CALL  ioctl(2,_IO('T',0x1,0),0x7f7fffffdb40)
 |   7829   7829 bash     RET   ioctl 0
 |   7829   7829 bash     CALL  mmap(0,0x1000,PROT_READ|PROT_WRITE,0x22<PRIVATE,RENAME,FILE,ALIGN=NONE>,0xffffffff,0)
 |   7829   7829 bash     RET   mmap 140187597262848/0x7f7ff7efd000
 |   7829   7829 bash     CALL  write(2,0x7f7ff7efd000,0x3f)
 |   7829   7829 bash     GIO   fd 2 wrote 63 bytes
 |        "do_ypcall: clnt_call: RPC: Unable to send; errno = Bad address\n"
 | 
 | ---
 | 
 | On NetBSD/amd64 7.2 it works without problem:
 | 
 | ---
 |    201    201 bash     CALL  sendto(5,0x6b0b9c,0x4c,0,0x6ae8a8,0x10)
 |    201    201 bash     MISC  linux/sockaddr: 16, 020002fbc0a814010000000000000000
 |    201    201 bash     MISC  mbsoname: [192.168.20.1]
 |    201    201 bash     MISC  msghdr: [name=0xfffffe81b108a800, namelen=16, iov=0xfffffe81003dfe48, iovlen=1, control=0x0, controllen=2164428672, flags=1000000]
 |    201    201 bash     GIO   fd 5 wrote 76 bytes
 | ---
 | 
 | Applying changes in your commit to netbsd-8 also fixes the problem.
 | However it requires bump of the kernel revision (i.e. module ABI change)
 | as the log message said.
 | 
 | Is there any proper way to also fix this in the netbsd-8 branch,
 | for major users who need to run linux binaries with NIS?

 I guess we should bump the version to:

 #define        __NetBSD_Version__      800000100       /* NetBSD 8.00.01 */

 and make sure that the change is pulled up to all the -8 branches.

 christos

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: christos@zoulas.com
Cc: gnats-bugs@NetBSD.org, pullup-8@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: PR/53103 CVS commit: src/sys
Date: Mon, 24 Sep 2018 11:29:16 +0900

 > I guess we should bump the version to:
 > 
 > #define        __NetBSD_Version__      800000100       /* NetBSD 8.00.01 */
 > 
 > and make sure that the change is pulled up to all the -8 branches.

 I'm afraid this fails because the version strings in the comment
 at the line is used as uname(3)'s version ("osrelease[] in the kernel)
 by sys/conf/osrelease.sh and sys/conf/newvers.sh.

 On the other hand osrelease.sh also claims:

  https://nxr.netbsd.org/xref/src/sys/conf/osrelease.sh?r=1.122#39
 >> # Search for line
 >> # #define __NetBSD_Version__ <ver_num> /* NetBSD <ver_text> */
 >> #
 >> # <ver_num> and <ver_text> should match!

 Is there any document how __NetBSD__ in param.h should be updated,
 especially for release branches?

 ---
 Izumi Tsutsui

From: christos@zoulas.com (Christos Zoulas)
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@NetBSD.org, pullup-8@netbsd.org
Subject: Re: PR/53103 CVS commit: src/sys
Date: Sun, 23 Sep 2018 22:46:34 -0400

 On Sep 24, 11:29am, tsutsui@ceres.dti.ne.jp (Izumi Tsutsui) wrote:
 -- Subject: Re: PR/53103 CVS commit: src/sys

 | > I guess we should bump the version to:
 | > 
 | > #define        __NetBSD_Version__      800000100       /* NetBSD 8.00.01 */
 | > 
 | > and make sure that the change is pulled up to all the -8 branches.
 | 
 | I'm afraid this fails because the version strings in the comment
 | at the line is used as uname(3)'s version ("osrelease[] in the kernel)
 | by sys/conf/osrelease.sh and sys/conf/newvers.sh.
 | 
 | On the other hand osrelease.sh also claims:
 | 
 |  https://nxr.netbsd.org/xref/src/sys/conf/osrelease.sh?r=1.122#39
 | >> # Search for line
 | >> # #define __NetBSD_Version__ <ver_num> /* NetBSD <ver_text> */
 | >> #
 | >> # <ver_num> and <ver_text> should match!
 | 
 | Is there any document how __NetBSD__ in param.h should be updated,
 | especially for release branches?

 I am not sure how it fails. It prints:
 8.0.01

 It is either that or 8.01... I always intended that the pp was reserved
 for patches :-)

 christos

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: christos@zoulas.com
Cc: gnats-bugs@NetBSD.org, pullup-8@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: PR/53103 CVS commit: src/sys
Date: Mon, 24 Sep 2018 12:05:02 +0900

 > | Is there any document how __NetBSD__ in param.h should be updated,
 > | especially for release branches?
 > 
 > I am not sure how it fails. It prints:
 > 8.0.01

 In that case uname(1) (and vers.c) on the built kernel will also say
 > NetBSD 8.0.01 (GENERIC) #1: Mon Sep 24 11:58:36 JST 2018
 Is it your intention for the next release?

 There is an old discussion about __NetBSD_Version__ for release branches
 but there is no conclusion?
  https://mail-index.netbsd.org/tech-kern/2012/01/10/msg012382.html

 ---
 Izumi Tsutsui

From: Martin Husemann <martin@duskware.de>
To: Christos Zoulas <christos@zoulas.com>
Cc: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, gnats-bugs@NetBSD.org,
	pullup-8@netbsd.org
Subject: Re: PR/53103 CVS commit: src/sys
Date: Mon, 24 Sep 2018 09:46:23 +0200

 On Sun, Sep 23, 2018 at 09:59:06PM -0400, Christos Zoulas wrote:
 > I guess we should bump the version to:
 > 
 > #define        __NetBSD_Version__      800000100       /* NetBSD 8.00.01 */
 > 
 > and make sure that the change is pulled up to all the -8 branches.

 No, we can not break the ABI on release branches (module loading code
 does not check the patch level field on != .99 branches).

 We would need a proper fix or hack especially for the branch that avoids this.

 Maybe duplicate the function that got an extra argument with a new name
 and use that everywhere the new arg is important?
 So all new compiled modules would also use the new function, but old
 modules still would work using the old version.

 Martin

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: PR/53103 CVS commit: src/sys
Date: Mon, 24 Sep 2018 10:04:14 +0000

 Bump it to 8.1? we aren't going to have teeny versions.

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, van.fstd@gmail.com
Subject: Re: PR/53103 CVS commit: src/sys
Date: Mon, 24 Sep 2018 12:14:24 +0200

 On Mon, Sep 24, 2018 at 10:05:01AM +0000, coypu@sdf.org wrote:
 >  Bump it to 8.1? we aren't going to have teeny versions.

 Still needs to be the same ABI (at least upwards compatible). We assume
 that if you install newer modules, the kernel is newer as well.

 Martin

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: martin@netbsd.org, christos@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: PR/53103 CVS commit: src/sys
Date: Fri, 16 Nov 2018 01:52:53 +0900

 martin@ wrote:

 >  No, we can not break the ABI on release branches (module loading code
 >  does not check the patch level field on != .99 branches).
 >  
 >  We would need a proper fix or hack especially for the branch that avoids this.
 >  
 >  Maybe duplicate the function that got an extra argument with a new name
 >  and use that everywhere the new arg is important?
 >  So all new compiled modules would also use the new function, but old
 >  modules still would work using the old version.

 http://www.nerv.org/netbsd/?q=id:20180316T172504Z.13d546ff8678da724b3c16167900ffb31d5e12c4
 In this original commit, only linux_sys_sendto() in
 compat/linux/common/linux_socket.c takes UIO_SYSSPACE.

 However, the linux_sys_sendto() calls do_sys_sendmsg(), and it calls
 do_sys_sendmsg_so(), then do_sys_sendmsg_so() calls sockargs() with
 UIO_USERSPACE if MSG_NAMEMBUF is not set.

 I'm not sure if changing sockargs() API was worth enough because
 the following dumb patch against linux_sys_sendto() can also avoid the
 "sockargs cannot handle msg_name already copied into the kernel space"
 problem.

 Index: sys/compat/linux/common/linux_socket.c
 ===================================================================
 RCS file: /cvsroot/src/sys/compat/linux/common/linux_socket.c,v
 retrieving revision 1.138.6.2
 diff -u -p -d -r1.138.6.2 linux_socket.c
 --- sys/compat/linux/common/linux_socket.c	12 May 2018 10:29:08 -0000	1.138.6.2
 +++ sys/compat/linux/common/linux_socket.c	15 Nov 2018 16:34:13 -0000
 @@ -401,6 +401,7 @@ linux_sys_sendto(struct lwp *l, const st
  	struct msghdr   msg;
  	struct iovec    aiov;
  	struct sockaddr_big nam;
 +	struct mbuf *m;
  	int bflags;
  	int error;

 @@ -415,13 +416,31 @@ linux_sys_sendto(struct lwp *l, const st
  	msg.msg_control = NULL;

  	if (SCARG(uap, tolen)) {
 +		size_t solen;
 +
  		/* Read in and convert the sockaddr */
  		error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, to),
  		    SCARG(uap, tolen));
  		if (error)
  			return (error);
 -		msg.msg_name = &nam;
 -		msg.msg_namelen = SCARG(uap, tolen);
 +
 +		/*
 +		 * XXX
 +		 * Copy sockaddr_big to mbuf because sockargs() called from
 +		 * do_sys_sendmsg_so() can't handle sockaddr in msg_name
 +		 * already copied into the kernel space.
 +		 */
 +		solen = nam.sb_len;
 +		m = m_get(M_WAIT, MT_SONAME);
 +		if (solen > MLEN) {
 +			MEXTMALLOC(m, solen, M_WAITOK);
 +		}
 +		m->m_len = solen;
 +		memcpy(mtod(m, void *), &nam, solen);
 +
 +		msg.msg_flags |= MSG_NAMEMBUF;
 +		msg.msg_name = m;
 +		msg.msg_namelen = solen;
  	}

  	msg.msg_iov = &aiov;


 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org, christos@netbsd.org
Cc: martin@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: PR/53103 CVS commit: src/sys
Date: Sat, 24 Nov 2018 01:19:19 +0900

 > I'm not sure if changing sockargs() API was worth enough because
 > the following dumb patch against linux_sys_sendto() can also avoid the
 > "sockargs cannot handle msg_name already copied into the kernel space"
 > problem.

  :

 If there is no particular comments, I'll send a pullup request
 to apply the patch against linux_sys_sendto().

 At least NIC (YP) on Linux binaries works with the patch on
 NetBSD/i386 and NetBSD/amd64 8.0.

 ---
 Izumi Tsutsui

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53103 CVS commit: [netbsd-8] src/sys/compat/linux/common
Date: Sat, 8 Dec 2018 12:24:18 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Dec  8 12:24:18 UTC 2018

 Modified Files:
 	src/sys/compat/linux/common [netbsd-8]: linux_socket.c

 Log Message:
 Apply patch, requested by tsutsui in ticket #1132:

 Different solution for the fix in

 	sys/compat/linux/common/linux_socket.c	rev 1.140

 The solution in -current could not be directly used as it required a kernel
 version bump and broke the ABI. Work around it differently here.

 Fixes linux emulation of sendto(2), PR 53103.


 To generate a diff of this commit:
 cvs rdiff -u -r1.138.6.2 -r1.138.6.3 \
     src/sys/compat/linux/common/linux_socket.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.