Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/compat/linux/common Apply patch, requested by tsutsui...



details:   https://anonhg.NetBSD.org/src/rev/38295c108cf5
branches:  netbsd-8
changeset: 446499:38295c108cf5
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Dec 08 12:24:18 2018 +0000

description:
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.

diffstat:

 sys/compat/linux/common/linux_socket.c |  27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r a1f2f7f0ee1c -r 38295c108cf5 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Sat Dec 08 12:17:13 2018 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Sat Dec 08 12:24:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.c,v 1.138.6.2 2018/05/12 10:29:08 martin Exp $    */
+/*     $NetBSD: linux_socket.c,v 1.138.6.3 2018/12/08 12:24:18 martin Exp $    */
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.2 2018/05/12 10:29:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.3 2018/12/08 12:24:18 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -401,6 +401,7 @@
        struct msghdr   msg;
        struct iovec    aiov;
        struct sockaddr_big nam;
+       struct mbuf *m;
        int bflags;
        int error;
 
@@ -415,13 +416,31 @@
        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;



Home | Main Index | Thread Index | Old Index