Home | History | Annotate | Download | only in netbsd32
History log of /src/sys/compat/netbsd32/netbsd32_socket.c
RevisionDateAuthorComments
 1.56  19-Jan-2021  simonb The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.55  19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.54  18-Jan-2021  simonb s/u_intN_t/uintN_t/
 1.53  28-Sep-2019  mlelstv branches: 1.53.8;
signed/unsigned comparison.
 1.52  27-Sep-2019  mlelstv Ensure failure if resid goes negative.
 1.51  27-Sep-2019  mlelstv signed/unsigned mismatch.
 1.50  26-Sep-2019  christos use size_t for counters (which are compared and set with unsigneds)
 1.49  14-Nov-2018  hannken branches: 1.49.4;
Apply the recent fixes to {send,recv}mmsg() to their compat variants.
 1.48  12-Nov-2018  maxv Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.47  13-May-2018  christos branches: 1.47.2;
PR/53280: Andreas Gustafsson: Fix panic in the fdpass test. This is probably
the only 32 bit binary in the tests...
 1.46  10-May-2018  christos add {send,recv}mmsg
 1.45  03-May-2018  christos Fix COMPAT_NETBSD32 cmsg handling:

1. alignment was wrong for > 1 message
2. macros were doing incorrect pointer comparisons, fortunately ending
the iteration early after the fists cmsg instead of crashing.
3. don't output 32 bit ktrace records for cmsg. 32 bit programs running
under emulation on 64 bit systems should produce 64 bit ktrace records
so that the native ktrace can handle the records; remove extra arguments
that are now not needed (the 32 bit msghdr).
4. output the correct type for cmsg trace records.
5. output all the cmsg records in traces instead of just the first one.

Welcome to 8.99.15 because of the argument removal.

XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR
macros...
 1.44  13-Sep-2016  martin branches: 1.44.8; 1.44.14;
Make the ktrace record written by do_sys_sendmsg/do_sys_recvmsg overridable
by the caller. Use this in compat_netbsd32 to log the 32bit version, so
the 32bit userland kdump is happy.
 1.43  08-Sep-2016  martin recvmsg: ktrace the 32bit message header, not the native (64bit) version.
 1.42  22-Jul-2015  maxv Memory leak, triggerable from an unprivileged user.
 1.41  18-Aug-2012  martin branches: 1.41.2; 1.41.14; 1.41.16;
Do not use a userland pointer, but the copied-in kernel version instead.
While there, reorder loop end condition for efficency.
Fixes net/fdpass tests on all archs with separate kernel/userland VA.
 1.40  30-Jul-2012  matt Make SCM_RIGHTS work correctly. (make sure to advance m if we've completely
dealt with, the next mbuf (if any) comes into play).
 1.39  20-Jan-2012  joerg branches: 1.39.2;
Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.38  13-Jan-2012  joerg Reduce difference between recvfrom/recvmsg for netbsd32 and the native
version. This fixes the bug of lost file descriptors when the control
space is not large enough.
 1.37  23-Apr-2010  rmind branches: 1.37.8; 1.37.12;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.36  22-Jul-2009  njoly branches: 1.36.2; 1.36.4;
Make compat netbsd32 sendmsg follow the native version by allowing
empty messages. This let unfdpass regression test work as expected.
 1.35  15-Jun-2009  njoly Make netbsd32 sendmsg(2), do not use an uninitialised value for
fetching iovec structures.
While here, sync recvmsg(2) to avoid some unneeded casts.
 1.34  17-Dec-2008  cegger branches: 1.34.2; 1.34.4;
kill MALLOC and FREE macros.
 1.33  24-Jun-2008  ad branches: 1.33.4; 1.33.12;
Replace references to getsock/getvnode.
 1.32  29-May-2008  mrg branches: 1.32.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.31  21-Mar-2008  ad branches: 1.31.2; 1.31.4; 1.31.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.30  20-Dec-2007  dsl branches: 1.30.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.29  08-Dec-2007  dsl branches: 1.29.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.28  04-Dec-2007  dsl Remove all the __P
 1.27  15-Aug-2007  ad branches: 1.27.2; 1.27.8; 1.27.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.26  01-Jun-2007  dsl branches: 1.26.2; 1.26.6;
Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.
 1.25  31-May-2007  christos message size == 0 is valid. From Markus Mayer
 1.24  18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.23  16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.22  04-Mar-2007  christos branches: 1.22.2; 1.22.4; 1.22.6;
fix fallout from caddr_t changes.
 1.21  04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20  09-Feb-2007  ad branches: 1.20.2;
Merge newlock2 to head.
 1.19  19-Mar-2006  matt branches: 1.19.8;
More variable sized MALLOC -> malloc changes.
 1.18  18-Mar-2006  matt MALLOC -> malloc
 1.17  01-Mar-2006  yamt branches: 1.17.2; 1.17.4; 1.17.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.16  11-Dec-2005  christos branches: 1.16.2; 1.16.4; 1.16.6;
merge ktrace-lwp.
 1.15  19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.14  31-May-2005  christos branches: 1.14.2;
- add const
- avoid shadowed variables.
 1.13  26-Feb-2005  perry nuke trailing whitespace
 1.12  21-Oct-2003  fvdl branches: 1.12.8; 1.12.10;
Fix some int vs. NULL comparisons.
 1.11  29-Jun-2003  fvdl branches: 1.11.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.10  29-Jun-2003  martin struct proc * -> struct lwp *
 1.9  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.8  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.7  23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.6  13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.5  17-Jul-2001  jdolecek Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.
 1.4  25-Jun-2001  jdolecek branches: 1.4.2;
Back off the sendit()/recvit() change, some have problems with it
 1.3  25-Jun-2001  jdolecek Add 'kernsa' parameter for sendit()/recvit(); if nonzero, msg->msg_name
is supposed to point directly to struct mbuf or struct sockaddr in kernel
space as appropriate, rather than being a pointer to memory in userland.

This is to be used by compat/* when emulation needs to wrap
send{to|msg}(2)/recv{from|msg}(2) and modify the passed struct
sockaddr.
 1.2  30-May-2001  mrg use _KERNEL_OPT.
 1.1  08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.6  11-Nov-2002  nathanw Catch up to -current
 1.1.4.5  23-Aug-2002  petrov lwpification.
 1.1.4.4  29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.3  14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2  24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1  21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2  11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1  08-Feb-2001  bouyer file netbsd32_socket.c was added on branch thorpej_scsipi on 2001-02-11 19:14:17 +0000
 1.4.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1  03-Aug-2001  lukem update to -current
 1.11.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.11.2.3  26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.11.2.2  03-Aug-2004  skrll Sync with HEAD
 1.11.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.12.10.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.8.1  29-Apr-2005  kent sync with -current
 1.14.2.6  24-Mar-2008  yamt sync with head.
 1.14.2.5  21-Jan-2008  yamt sync with head
 1.14.2.4  07-Dec-2007  yamt sync with head
 1.14.2.3  03-Sep-2007  yamt sync with head.
 1.14.2.2  26-Feb-2007  yamt sync with head.
 1.14.2.1  21-Jun-2006  yamt sync with head.
 1.16.6.1  22-Apr-2006  simonb Sync with head.
 1.16.4.1  09-Sep-2006  rpaulo sync with head
 1.16.2.1  18-Feb-2006  yamt adapt the rest of MI code.
 1.17.6.1  28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.17.4.1  19-Apr-2006  elad sync with head.
 1.17.2.1  01-Apr-2006  yamt sync with head.
 1.19.8.1  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.20.2.2  24-Mar-2007  yamt sync with head.
 1.20.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.22.6.2  29-Mar-2007  reinoud Pullup to -current
 1.22.6.1  18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.22.4.1  11-Jul-2007  mjf Sync with head.
 1.22.2.3  20-Aug-2007  ad Sync with HEAD.
 1.22.2.2  09-Jun-2007  ad Sync with head.
 1.22.2.1  10-Apr-2007  ad Sync with head.
 1.26.6.2  09-Dec-2007  jmcneill Sync with HEAD.
 1.26.6.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.26.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.27.10.2  26-Dec-2007  ad Sync with head.
 1.27.10.1  08-Dec-2007  ad Sync with head.
 1.27.8.2  27-Dec-2007  mjf Sync with HEAD.
 1.27.8.1  08-Dec-2007  mjf Sync with HEAD.
 1.27.2.1  09-Jan-2008  matt sync with HEAD
 1.29.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.30.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.30.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.30.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.30.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.31.6.4  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.31.6.3  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.31.6.2  14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.31.6.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.31.4.4  11-Aug-2010  yamt sync with head.
 1.31.4.3  19-Aug-2009  yamt sync with head.
 1.31.4.2  20-Jun-2009  yamt sync with head
 1.31.4.1  04-May-2009  yamt sync with head.
 1.31.2.1  04-Jun-2008  yamt sync with head
 1.32.2.1  27-Jun-2008  simonb Sync with head.
 1.33.12.1  09-Jun-2010  matt Fix socket passing in netbsd32 compat. unfdpasses and incoming ssh
interactive session now work.
 1.33.4.1  19-Jan-2009  skrll Sync with HEAD.
 1.34.4.1  23-Jul-2009  jym Sync with HEAD.
 1.34.2.2  17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.34.2.1  17-Dec-2008  cegger file netbsd32_socket.c was added on branch christos-time_t on 2008-12-17 20:51:35 +0000
 1.36.4.1  30-May-2010  rmind sync with head
 1.36.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.37.12.1  18-Feb-2012  mrg merge to -current.
 1.37.8.2  30-Oct-2012  yamt sync with head
 1.37.8.1  17-Apr-2012  yamt sync with head
 1.39.2.3  21-Apr-2016  martin Pull up following revision(s) (requested by christos in ticket #1378):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.39.2.2  18-Aug-2012  riz branches: 1.39.2.2.4; 1.39.2.2.6;
Pull up following revision(s) (requested by martin in ticket #510):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.41
Do not use a userland pointer, but the copied-in kernel version instead.
While there, reorder loop end condition for efficency.
Fixes net/fdpass tests on all archs with separate kernel/userland VA.
 1.39.2.1  30-Jul-2012  martin Pull up following revision(s) (requested by matt in ticket #452):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.40
Make SCM_RIGHTS work correctly. (make sure to advance m if we've completely
dealt with, the next mbuf (if any) comes into play).
 1.39.2.2.6.1  21-Apr-2016  martin Pull up following revision(s) (requested by christos in ticket #1378):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.39.2.2.4.1  21-Apr-2016  martin Pull up following revision(s) (requested by christos in ticket #1378):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.41.16.2  05-Oct-2016  skrll Sync with HEAD
 1.41.16.1  22-Sep-2015  skrll Sync with HEAD
 1.41.14.2  21-Nov-2018  martin Pull up following revision(s) (requested by maxv in ticket #1652):

sys/compat/netbsd32/netbsd32_socket.c: revision 1.48 (via patch)

Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.41.14.1  08-Aug-2015  martin branches: 1.41.14.1.2; 1.41.14.1.6;
Pull up following revision(s) (requested by maxv in ticket #941):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.41.14.1.6.1  21-Nov-2018  martin Pull up following revision(s) (requested by maxv in ticket #1652):

sys/compat/netbsd32/netbsd32_socket.c: revision 1.48 (via patch)

Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.41.14.1.2.1  21-Nov-2018  martin Pull up following revision(s) (requested by maxv in ticket #1652):

sys/compat/netbsd32/netbsd32_socket.c: revision 1.48 (via patch)

Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.41.2.1  03-Dec-2017  jdolecek update from HEAD
 1.44.14.2  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.44.14.1  21-May-2018  pgoyette Sync with HEAD
 1.44.8.2  21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1833):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.44.8.1  13-Nov-2018  snj Pull up following revision(s) (requested by maxv in ticket #1093):
sys/compat/netbsd32/netbsd32_socket.c: 1.48
Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.47.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.47.2.1  10-Jun-2019  christos Sync with HEAD
 1.49.4.1  03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.53.8.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed