summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_socket.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce some more SO_ option equivalents from Linux to FreeBSD.kib2007-02-011-0/+18
| | | | | | | The msg variable in linux_recvmsg() was not initialized. Copy it from userspace. Submitted by: rdivacky
* MFp4:netchild2006-09-231-2/+7
| | | | | | | | | | | | | | | - Linux returns ENOPROTOOPT in a case of not supported opt to setsockopt. - Return EISDIR in pread() when arg is a directory. - Return EINVAL instead of EFAULT when namelen is not correct in accept(). - Return EINVAL instead of EACCESS if invalid access mode is entered in access(). - Return EINVAL instead of EADDRNOTAVAIL in a case of bad salen param to bind(). Submitted by: rdivacky Tested with: LTP (vfork01 fails now, but it seems to be a race and not caused by those changes) MFC after: 1 week
* Don't free the sockaddr in kern_bind() and kern_connect() as not alljhb2006-07-191-1/+4
| | | | | callers pass a sockaddr allocated via malloc() from M_SONAME anymore. Instead, free it in the callers when necessary.
* Add a kern_close() so that the ABIs can close a file descriptor w/o havingjhb2006-07-081-5/+1
| | | | to populate a close_args struct and change some of the places that do.
* Now that we don't have a linuxolator on alpha anymore:netchild2006-05-101-88/+29
| | | | | - unifdef __alpha__ - revert rev. 1.66 of linux_socket.c
* Annotate uses of fgetsock() with indications that they should relyrwatson2006-04-011-0/+4
| | | | | | | on their existing file descriptor references to sockets, rather than use fgetsock() to retrieve a direct socket reference. MFC after: 3 months
* Fix the LINT build on alpha:netchild2006-03-211-32/+82
| | | | | | | - rename some file local structure definitions, the names clash with autogenerated names - on !alpha add some compatibility defines for those renamed structures - make some functions globally visible on alpha
* Unbreak COMPAT_LINUX32 option support on amd64.ru2006-03-191-0/+1
| | | | Broken by: netchild
* Fixup some problems in my previous commit (COMPAT_43).netchild2006-03-181-1/+0
| | | | Pointyhat to: netchild
* Get rid of the need of COMPAT_43 in the linuxolator.netchild2006-03-181-15/+84
| | | | | Submitted by: Divacky Roman <xdivac02@stud.fit.vutbr.cz> Obtained from: DragonFly (some parts)
* Add \n to log() message.glebius2005-12-271-1/+1
| | | | Submitted by: Stanislaw Halik <weirdo tehran.lain.pl>
* Back out alpha/alpha/trap.c:1.124, osf1_ioctl.c:1.14, osf1_misc.c:1.57,rwatson2005-09-281-2/+0
| | | | | | | | | | | | | | | | | | | | osf1_signal.c:1.41, amd64/amd64/trap.c:1.291, linux_socket.c:1.60, svr4_fcntl.c:1.36, svr4_ioctl.c:1.23, svr4_ipc.c:1.18, svr4_misc.c:1.81, svr4_signal.c:1.34, svr4_stat.c:1.21, svr4_stream.c:1.55, svr4_termios.c:1.13, svr4_ttold.c:1.15, svr4_util.h:1.10, ext2_alloc.c:1.43, i386/i386/trap.c:1.279, vm86.c:1.58, unaligned.c:1.12, imgact_elf.c:1.164, ffs_alloc.c:1.133: Now that Giant is acquired in uprintf() and tprintf(), the caller no longer leads to acquire Giant unless it also holds another mutex that would generate a lock order reversal when calling into these functions. Specifically not backed out is the acquisition of Giant in nfs_socket.c and rpcclnt.c, where local mutexes are held and would otherwise violate the lock order with Giant. This aligns this code more with the eventual locking of ttys. Suggested by: bde
* Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(),rwatson2005-09-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | as they both interact with the tty code (!MPSAFE) and may sleep if the tty buffer is full (per comment). Modify all consumers of uprintf() and tprintf() to hold Giant around calls into these functions. In most cases, this means adding an acquisition of Giant immediately around the function. In some cases (nfs_timer()), it means acquiring Giant higher up in the callout. With these changes, UFS no longer panics on SMP when either blocks are exhausted or inodes are exhausted under load due to races in the tty code when running without Giant. NB: Some reduction in calls to uprintf() in the svr4 code is probably desirable. NB: In the case of nfs_timer(), calling uprintf() while holding a mutex, or even in a callout at all, is a bad idea, and will generate warnings and potential upset. This needs to be fixed, but was a problem before this change. NB: uprintf()/tprintf() sleeping is generally a bad ideas, as is having non-MPSAFE tty code. MFC after: 1 week
* Add missing locking to linux_connect() so that it can be marked MP safe:jhb2005-07-091-8/+15
| | | | | | | | | - Conditionally grab Giant around the EISCONN hack at the end based on debug.mpsafenet. - Protect access to so_emuldata via SOCK_LOCK. Reviewed by: rwatson Approved by: re (scottl)
* Reject packets larger than IP_MAXPACKET in linux_sendto() for socketsdas2005-03-231-2/+3
| | | | | | | | | | | with the IP_HDRINCL option set. Without this change, a Linux process with access to a raw socket could cause a kernel panic. Raw sockets must be created by root, and are generally not consigned to untrusted applications; hence, the security implications of this bug are minimal. I believe this only affects 6-CURRENT on or after 2005-01-30. Found by: Coverity Prevent analysis tool Security: Local DOS
* Add kernel-only flag MSG_NOSIGNAL to be used in emulation layers to surpresssobomax2005-03-081-27/+4
| | | | | | | | SIGPIPE signal for the duration of the sento-family syscalls. Use it to replace previously added hack in Linux layer based on temporarily setting SO_NOSIGPIPE flag. Suggested by: alfred
* Handle MSG_NOSIGNAL flag in linux_send() by setting SO_NOSIGPIPE on socketsobomax2005-03-071-2/+25
| | | | | | | | | | | | | | for the duration of the send() call. Such approach may be less than ideal in threading environment, when several threads share the same socket and it might happen that several of them are calling linux_send() at the same time with and without SO_NOSIGPIPE set. However, such race condition is very unlikely in practice, therefore this change provides practical improvement compared to the previous behaviour. PR: kern/76426 Submitted by: Steven Hartland <killing@multiplay.co.uk> MFC after: 3 days
* Extend kern_sendit() to take another enum uio_seg argument, which specifiessobomax2005-01-301-24/+20
| | | | | | | where the buffer to send lies and use it to eliminate yet another stackgap in linuxlator. MFC after: 2 weeks
* Match the LINUX32's style with existing styleobrien2005-01-141-4/+4
| | | | | | Submitted by: Jung-uk Kim <jkim@niksun.com> Use positive, not negative logic.
* Fix the ABI wrappers to use kern_fcntl() rather than calling fcntl()jhb2004-08-241-11/+4
| | | | | | | | directly. This removes a few more users of the stackgap and also marks the syscalls using these wrappers MP safe where appropriate. Tested on: i386 with linux acroread5 Compiled on: i386, alpha LINT
* Don't try to translate the control message unless we're certain it'sdes2004-08-231-1/+2
| | | | | | | | valid; otherwise a caller could trick us into changing any 32-bit word in kernel memory to LINUX_SOL_SOCKET (0x00000001) if its previous value is SOL_SOCKET (0x0000ffff). MFC after: 3 days
* Changes to MI Linux emulation code necessary to run 32-bit Linux binariestjr2004-08-161-51/+67
| | | | | | | | | | | | | | | on AMD64, and the general case where the emulated platform has different size pointers than we use natively: - declare certain structure members as l_uintptr_t and use the new PTRIN and PTROUT macros to convert to and from native pointers. - declare some structures __packed on amd64 when the layout would differ from that used on i386. - include <machine/../linux32/linux.h> instead of <machine/../linux/linux.h> if compiling with COMPAT_LINUX32. This will need to be revisited before 32-bit and 64-bit Linux emulation support can coexist in the same kernel. - other small scattered changes. This should be a no-op on i386 and Alpha.
* I missed two pieces of the commit to this file. Robert has alreadydwmalone2004-07-181-1/+1
| | | | added one, this adds the other.
* Remove 'sg' argument to linux_sendto_hdrincl, which is what I think wasrwatson2004-07-181-1/+1
| | | | intended. This fixes the build, but might require revision.
* Add a kern_setsockopt and kern_getsockopt which can read the optiondwmalone2004-07-171-65/+19
| | | | | | values from either user land or from the kernel. Use them for [gs]etsockopt and to clean up some calls to [gs]etsockopt in the Linux emulation code that uses the stackgap.
* Clean up and wash struct iovec and struct uio handling.phk2004-07-101-20/+7
| | | | | | | | | | | | Add copyiniov() which copies a struct iovec array in from userland into a malloc'ed struct iovec. Caller frees. Change uiofromiov() to malloc the uio (caller frees) and name it copyinuio() which is more appropriate. Add cloneuio() which returns a malloc'ed copy. Caller frees. Use them throughout.
* Use a couple of regular kernel entry points, rather than COMPAT_43phk2004-07-081-4/+12
| | | | entry points.
* Quick fix for LINT breakage caused by interface changes in accept(2), etc.bde2003-12-251-33/+36
| | | | | | | | | | | | | | | | | | | The log message for rev.1.160 of kern/uipc_syscalls.c and associated changes only claimed to add restrict qualifiers (which have no effect in the kernel so they probably shouldn't be added), but the following interface changes were also made: - caddr_t to `void *' and `struct sockaddr_t *' - `int *' to `socklen_t *'. These interface changes are not quite null, and this fix is quick (like the changes in uipc_syscalls 1.160) because it uses bogus casts instead of complete bounds-checked conversions. Things should be fixed better when the conversions can be done without using the stack gap. linux_check_hdrincl() already uses the stack gap and is fixed completely though the type mismatches in it were not fatal (there were only fatal type mismatches from unopaquing pointers to [o]sockaddr't's -- the difference between accept()'s args and oaccept()'s args is now non-opaque, but this is not reflected in their args structs).
* Use kern_sendit rather than sendit for the Linux send* syscalls.dwmalone2003-11-091-144/+105
| | | | | This means we can avoid using the stack gap for most send* syscalls now (it is still used in the IP_HDRINCL case).
* Fix some problems in linux_sendmsg() and linux_recvmsg().iwasaki2003-10-111-36/+38
| | | | | | | | | | | - Allocate storage for uap->msg always because it is copyin()'ed in native sendmsg(). - Convert sockopt level from Linux to FreeBSD after native recvmsg() calling. - Some cleanups. Tested with: Oracle 9i shared server connection mode. MFC after: 1 week
* Use __FBSDID().obrien2003-06-101-2/+3
|
* Deprecate machine/limits.h in favor of new sys/limits.h.kan2003-04-291-2/+1
| | | | | | | Change all in-tree consumers to include <sys/limits.h> Discussed on: standards@ Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>
* Clean up whitespace and remove register keyword.des2003-03-031-2/+2
|
* More caddr_t removal, in conjunction with copy{in,out}(9) this time.des2003-03-031-4/+4
| | | | Also clean up some egregious casts and incorrect use of sizeof.
* Add M_WAITOKume2003-02-201-1/+1
|
* 1) Linux_sendto was trashing the BSD sockaddr it put in the stackgap,dwmalone2003-02-081-14/+15
| | | | | | | | | | | | | | | so be more careful about calling stackgap_init. Tested by: Fred Souza <fred@storming.org> 2) Linux_sendmsg was forgetting to fill out the bsd_args struct. Reviewed by: ume 3) The args to linux_connect have differently named types on alpha and i386, so add a cast to stop gcc complaining. Spotted by: peter
* Avoid undefined symbol error with an IPv4 only kernel.ume2003-02-051-1/+9
| | | | Reported by: "Sergey A. Osokin" <osa@freebsd.org.ru>
* Add IPv6 support for Linuxlator.ume2003-02-031-88/+372
| | | | | Reviewed by: dwmalone MFC after: 10 days
* Back out last commit. Linux uses the old 4.3BSD sockaddr format.mini2002-09-241-19/+11
|
* Don't use compatability syscall wrappers in emulation code.mini2002-09-231-11/+19
| | | | | | This is needed for the COMPAT_FREEBSD3 option split. Reviewed by: alfred, jake
* Fix typo in the BSD copyright: s/withough/without/schweikh2002-06-021-1/+1
| | | | | Spotted and suggested by: des MFC after: 3 weeks
* Fix missing holdsock()->fgetsock()dillon2001-11-171-7/+5
| | | | Submitted by: Hisashi Hiramoto <hiramoto@phys.chs.nihon-u.ac.jp>
* Force the length of the sockaddr to be correct for AF_INET and AF_INET6fenner2001-10-261-2/+23
| | | | | | in bind() and connect(). Linux doesn't care if the length of the sockaddr matches its address family; FreeBSD does. This fixes the known issues with the resolver in linux_base-7.
* KSE Milestone 2julian2001-09-121-65/+65
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Round of cleanups and enhancements. These include (in random order):marcel2001-09-081-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Introduce private types for use in linux syscalls for two reasons: 1. establish type independence for ease in porting and, 2. provide a visual queue as to which syscalls have proper prototypes to further cleanup the i386/alpha split. Linuxulator types are prefixed by 'l_'. void and char have not been "virtualized". o Provide dummy functions for all syscalls and remove dummy functions or implementations of truely obsolete syscalls. o Sanitize the shm*, sem* and msg* syscalls. o Make a first attempt to implement the linux_sysctl syscall. At this time it only returns one MIB (KERN_VERSION), but most importantly, it tells us when we need to add additional sysctls :-) o Bump the kenel version up to 2.4.2 (this is not the same as the KERN_VERSION MIB, BTW). o Implement new syscalls, of which most are specific to i386. Our syscall table is now up to date with Linux 2.4.2. Some highlights: - Implement the 32-bit uid_t and gid_t bases syscalls. - Implement a couple of 64-bit file size/offset bases syscalls. o Fix or improve numerous syscalls and prototypes. o Reduce style(9) violations while I'm here. Especially indentation inconsistencies within the same file are addressed. Re-indenting did not obfuscate actual changes to the extend that it could not be combined. NOTE: I spend some time testing these changes and found that if there were regressions, they were not caused by these changes AFAICT. It was observed that installing a RH 7.1 runtime environment did make matters worse. Hangs and/or reboots have been observed with and without these changes, so when it failed to make life better in cases it doesn't look like it made it worse.
* Only pick up so_error the first time through with EISCONN, as advertised.jlemon2001-03-021-1/+1
| | | | | | The sense of the test was reversed, so we were returning EISCONN, then 0. Pointed out and tested by: Martin Blapp <mb@imp.ch>
* Correctly emulate linux_connect. For nonblocking sockets, the behaviorjlemon2001-03-011-51/+21
| | | | | | | | is to return EINPROGRESS, EALREADY, (so_error ONCE), EISCONN. Certain linux applications rely on the so_error (normally 0) being returned in order to operate properly. Tested by: Thomas Moestl <tmoestl@gmx.net>
* translate the flags in recvfrom and recvmsg from linux to bsd onesassar2000-12-191-2/+69
| | | | Approved by: marcel
* Don't auto-generate the syscalls.marcel2000-12-031-4/+0
|
* Use the linux_connect() on alpha rather than passing directly throughgallatin2000-11-161-1/+9
| | | | | | | | | | to our native connect(). This is required to deal with the differences in the way linux handles connects on non-blocking sockets. This gets the private beta of the Compaq Linux/alpha JDK working on FreeBSD/alpha Approved by: marcel
OpenPOWER on IntegriCloud