511 Commits

Author SHA1 Message Date
dfr
2c824ba34d Fix a harmless mismerge.
Pointed out by: jhb
2008-05-20 07:55:03 +00:00
dfr
0536363c85 MFC: kernel-mode NFS lock manager. 2008-04-24 10:46:25 +00:00
kib
ee9ecbab7b MFC rev. 1.89, 1.90:
Apply the LCONVPATH() to the (old) linux_stat() and linux_lstat() syscalls.
2008-01-09 16:07:32 +00:00
dwmalone
abadf7b17f The kernel version of Linux statfs64 is actually supposed to take
3 arguments, but we had forgotten the second argument. Also make the
Linux statfs64 struct depend on the architecture because it has an
extra 4 bytes padding on amd64 compared to i386.

The three argument fix is from David Taylor, the struct statfs64
stuff is my fault. With this patch I can install i386 Linux matlab
on an amd64 machine.

Approved by:	re (kensmith)
2007-12-08 08:48:08 +00:00
jhb
a6256653d9 MFC: Add kern_msgsnd() and kern_msgrcv() and use them to fix msgsnd()
and msgrcv() in 32-bit ABIs on 64-bit kernels.
2007-12-06 22:00:05 +00:00
jhb
f107dfa8f5 MFC: Sync up SYSV IPC with HEAD some:
- Add kern_semctl() and use it for Linux, IBCS2, and SVR4 ABIs.
- Don't pass a bufsz pointer to kern_shmctl() for operations that don't
  need it.
- Add module dependencies for SYSV IPC modules to IBCS2 and SVR4.
- Use kern_shmctl() in SVR4.
- Use kern_msgctl(), kern_semctl(), and kern_shmctl() in IBCS2.
- Mark linux_ipc(), svr4_sys_shmsys(), and svr4_sys_semsys() MPSAFE.
2007-12-03 21:53:23 +00:00
netchild
cba8561b2d Really commit the TIOCGPTN part (missing in the previous commit...). 2007-09-03 13:55:05 +00:00
netchild
68fcd79292 MFC:
- sync linuxulator:
   * de-COMPAT_43-ify:
     + socket related ioctl's
     This differs from -current, as the kernel ABI is different
     (kern_bind() and kern_connect() free the struct sockaddr on -stable
     themself, so two calls to free() are not included in this MFC).
   * bug-/compatibility-fixes
   * ioctl TIOCGPTN
   * 1 style(9)-fix

Tested by:	"Arno J. Klaassen" <arno@heho.snv.jussieu.fr>
2007-09-03 13:18:42 +00:00
netchild
5a60814e56 MFC:
- sync linuxulator:
   * add syscalls:
     + stat            (i386, amd64)
     + iopl            (i386, amd64)
     + mprotect        (i386)
     + rt_sigpending   (i386)
     + rt_sigtimedwait (i386)
     + statfs64        (i386, amd64)
     + utimes          (i386, amd64)
     + settimeofday    (amd64)
     + clock_*         (i386, amd64)
   * de-COMPAT_43-ify:
     + sethostname
     + lstat
     + ftruncate
     + nanosleep (i386)
   * add more dummy syscalls so that we know what is needed

Tested by:	bsam (on i386/amd64 with LTP 20070630)
2007-08-29 15:04:26 +00:00
netchild
ae2249d960 MFC (5 of X):
- linuxulator mmap handling
 - memleak fixes
 - extend linux errno mapping
 - handle address space limits for linux processes
 - sync linprocfs (/proc/sys/... part)

Compile tested by:	scf (i386, as part of a mega-MFC-patch)
Tested by:		Arno J. Klaassen <arno@heho.snv.jussieu.fr> (amd64)
2007-07-08 12:20:36 +00:00
netchild
962e1e6836 MFC (4 of X):
- don't limit number of syscalls to 255
 - handle more socket options
 - bug-/compatibility-fixes to linux
   * file related (includes fixes which prevent creation of strange files
     which can only be removed with a fsck)
   * make ping work
   * ...
 - add devfs to the file system type handling/translation

Compile tested by:	scf (i386, as part of a mega-MFC-patch)
Tested by:		Arno J. Klaassen <arno@heho.snv.jussieu.fr> (amd64)
2007-07-08 09:04:44 +00:00
netchild
b6ba7285b9 MFC (2 of X):
- some linuxulator style(9) fixes
 - add datatypes and definitions in preparation of further commits
 - use one (l_sigval) of the new datatypes on amd64 and get rid of a now unused
   include (this may or may not fix some signal handling issues on amd64) [1]
 - convert some unconditional debug handling into the common linuxulator way
 - use some more appropriate format string types in some debug printf's
 - convert signal validation into a macro

Except for [1] on amd64 there is no visible change to a normal user.

Tested by:	scf (i386), Arno J. Klaassen <arno@heho.snv.jussieu.fr> (amd64)
2007-07-08 08:41:09 +00:00
netchild
34d21d2a2c MFC (1 of X):
- easy linuxulator style(9) fixes (easy = hand removal of non-style code
   change sections in a full diff)

Tested by:	scf (i386), Arno J. Klaassen <arno@heho.snv.jussieu.fr> (amd64)
2007-07-08 08:26:10 +00:00
scottl
7964da46d3 MFC the scsi_sg driver. 2007-04-10 21:44:17 +00:00
cvs2svn
472436dd42 This commit was manufactured by cvs2svn to create branch 'RELENG_6'. 2006-12-20 22:02:46 +00:00
netchild
519d8f6986 MFC rev. 1.187:
- don't reboot() when feed with wrong parameters (and enough permissions) [1]
  - add support to power off the system [2]
  - check the linux magic values [3]

  Submitted by:		Marcin Cieslak <saper@SYSTEM.PL> [1,2]
  Modelled after:	linux man page of the reboot() syscall [3]
  Found by:		LTP testcase "reboot02" [1]
  Tested with:		LTP testcase "reboot02" [1,3]

Approved by:	re (hrs)
2006-09-23 10:36:57 +00:00
netchild
64e48c48e3 MFC rev 1.97:
The Linux unlink syscall uses a different errno value when trying to unlink
a directory.

PR:		102897 [1]  http://www.FreeBSD.org/cgi/query-pr.cgi?pr=102897
Noticed by:	Knut Anders Hatlen <kahatlen@gmail.com> [1], testrun with LTP
Submitted by:	Marcin Cieslak <saper@SYSTEM.PL>
Tested by:	netchild (LTP test run)
Approved by:	re
2006-09-17 10:56:15 +00:00
netchild
59692ae939 MFC:
- linux_misc.c 1.179
  Don't copyout/do unneccesary work if the buffer is a NULL pointer.

  Noticed by:     Dmitry Ganenko <dima@apk-inform.com>
  Reviewed by:    rdivacky (the original version as in emulation@)

- linprocfs.c 1.96:
  Improve linprovfs to provide/fix the
   - process state (idle, sleeping, running, ...) [1]
   - the process group ID of the process which owns the connected tty
   - some page fault stats
   - time spend in kernel/userland
   - priority/nice value
   - starttime [1]
   - memory/swap stats
   - scheduling policy

  Additionally add some new fields and correct some not filled out ones.

  This brings us down to 15 dummy fields.

  The fields marked with [1] are needed to get Oracle 10 running. The starttime
  field is not completely right, since it displays the _same_ starttime for
  _every_ process, but at least it is not 0 and Oracle accepts this.

  Noticed by:     Dmitry Ganenko <dima@apk-inform.com> [1]
  Reviewed by:    des, rdivacky

- pseudofs_vnops.c 1.60:
  Correctly calculate a buffer length. It was off by one so a read() returned
  one byte less than needed.

  Noticed by:     Dmitry Ganenko <dima@apk-inform.com>
  Testcase by:    Dmitry Ganenko <dima@apk-inform.com>
  Reviewed by:    des
  Submitted by:   rdivacky
  Sponsored by:   Google SoC 2006

All of those are needed for Oracle 10. Since previous Oracle versions work
just fine without those fixes, these patches can be seen as regression fixes
too. Because of this I think they are a RELENG_6_x candidate (MFC reminder
set).

MFC after:	1 month
2006-07-08 14:06:56 +00:00
ambrisko
a2a15d9794 Forgot to bring this fix into my commit tree to include opt_compat.h.
This should unbreak the amd64 build.
2006-06-15 19:08:03 +00:00
ambrisko
6ebd888016 MFC the enhancements to the Linux emulation layer so the MegaRAID SAS
management tools can work.  This is not totally connected to the build
yet.  The mfi(4) change have not been MFC'ed yet.  This will be done
shortly.  I'm trying to do this in chunks so I don't totally break
the build on a missed commit.  This has passed make universe a while
ago:
  Enhance the Linux emulation layer to make MegaRAID SAS managements tool happy.
  Add back in a scheme to emulate old type major/minor numbers via hooks into
  stat, linprocfs to return major/minors that Linux app's expect.  Currently
  only /dev/null is always registered.  Drivers can register via the Linux
  type shim similar to the ioctl shim but by using
  linux_device_register_handler/linux_device_unregister_handler functions.
  The structure is:

    struct linux_device_handler {
        char    *bsd_driver_name;
        char    *linux_driver_name;
        char    *bsd_device_name;
        char    *linux_device_name;
        int     linux_major;
        int     linux_minor;
        int     linux_char_device;
    };

  Linprocfs uses this to display the major number of the driver.  The
  soon to be available linsysfs will use it to fill in the driver name.
  Linux_stat uses it to translate the major/minor into Linux type values.

  Note major numbers are dynamically assigned via passing in a -1 for
  the major number so we don't need to keep track of them.

  This is somewhat needed due to us switching to our devfs.
2006-06-15 15:52:05 +00:00
jeff
1a868ce8ec MFC Rev 1.75
VFS SMP fixes, stack api, softupdates fixes.

Sponsored by:	Isilon Systems, Inc.
Approved by:	re (scottl)
2006-03-13 03:04:07 +00:00
jeff
9e2412596d MFC Rev 1.21
VFS SMP fixes, stack api, softupdates fixes.

Sponsored by:	Isilon Systems, Inc.
Approved by:	re (scottl)
2006-03-13 03:04:04 +00:00
delphij
19aa2b762e MFC revision 1.131
date: 2005/12/13 15:32:52;  author: delphij;  state: Exp;  lines: +5 -5
In Linux, kernel parameters passed to ioctl are by value, while in FreeBSD
they are passed by reference.  Handle the difference within the
linux_ioctl_termio on the LINUX_TCFLSH path.

Submitted by:   Jaroslav Drzik <jaro_AT_coop-voz_dot_sk>
Reminded by:	glebius
2006-01-11 15:40:00 +00:00
glebius
df3c4d7b56 MFC 1.62:
Add \n to log() message.
2006-01-10 10:13:43 +00:00
jhb
c240b8f56c MFC: Remove linux_mib_destroy() since MTX_SYSINIT's gaining of a SYSUNINIT
that called mtx_destroy() made it obsolete.
2005-12-22 21:25:20 +00:00
glebius
5b6819c0d6 MFC 1.26:
Suppress logging about unimplemented syscalls to one time per process. This
  prevents hard flood of the system console.

  Reviewed by:	bde
2005-12-19 17:06:51 +00:00
rodrigc
05573dfb34 MFC 1.29, 1.30:
Rewrite linux_ifconf() to be more like ifconf() in net/if.c
  so that we do not call uiomove() while IFNET_RLOCK() is held.
  This eliminates the witness warning:

  Calling uiomove() with the following non-sleepable locks held:
  exclusive sleep mutex ifnet r = 0 (0xc096dd60) locked @
  /usr/src/sys/modules/linux/../../compat/linux/linux_ioctl.c:2170

Approved by:	re (scottl)
2005-09-02 03:52:28 +00:00
rwatson
e13b2df854 Merge linux_ioctl.c:1.128 svr4_sockio.c:1.17 altq_cbq.c:1.3 if_oltr.c:1.38
if_pflog.c:1.14 if_pfsync.c:1.21 if_an.c:1.70 if_ar.c:1.72 if_arl.c:1.11
amrr.c:1.10 onoe.c:1.10 if_ath.c:1.101 awi.c:1.41 if_bfe.c:1.27
if_bge.c:1.93 if_cm_isa.c:1.7 smc90cx6.c:1.16 if_cnw.c:1.20 if_cp.c:1.25
if_cs.c:1.42 if_ct.c:1.26 if_cx.c:1.46 if_ed.c:1.256 if_em.c:1.68
if_en_pci.c:1.37 midway.c:1.66 if_ep.c:1.143 if_ex.c:1.58 if_fatm.c:1.20
if_fe.c:1.93 if_fwe.c:1.38 if_fwip.c:1.8 if_fxp.c:1.244 if_gem.c:1.33
if_hatm.c:1.25 if_hatm_intr.c:1.20 if_hatm_ioctl.c:1.13 if_hatm_rx.c:1.10
if_hatm_tx.c:1.14 if_hme.c:1.39 if_ie.c:1.104 if_ndis.c:1.101
if_ic.c:1.24 if_ipw.c:1.10 if_iwi.c:1.10 if_ixgb.c:1.13 if_lge.c:1.41
if_lnc.c:1.113 if_my.c:1.31 if_nge.c:1.77 if_nve.c:1.10 if_owi.c:1.12
if_patm.c:1.9 if_patm_intr.c:1.6 if_patm_ioctl.c:1.10 if_patm_tx.c:1.10
pdq_ifsubr.c:1.28 if_plip.c:1.38 if_ral.c:1.12 if_ral_pci.c:1.2
if_ray.c:1.81 if_rayvar.h:1.22 if_re.c:1.49 if_sbni.c:1.21 if_sbsh.c:1.14
if_sn.c:1.48 dp83932.c:1.21 if_snc_pccard.c:1.9 if_sr.c:1.70 if_tx.c:1.91
if_txp.c:1.33 if_aue.c:1.92 if_axe.c:1.32 if_cdce.c:1.8 if_cue.c:1.59
if_kue.c:1.66 if_rue.c:1.23 if_udav.c:1.16 if_ural.c:1.12 if_vge.c:1.16
if_vx.c:1.58 if_wi.c:1.185 if_wi_pci.c:1.26 if_wl.c:1.68 if_xe.c:1.60
if_xe_pccard.c:1.30 if_el.c:1.68 i4b_ipr.c:1.35 i4b_isppp.c:1.31
kern_poll.c:1.20 bridge.c:1.94 bridgestp.c:1.4 if_arcsubr.c:1.27
if_atm.h:1.24 if_atmsubr.c:1.40 if_bridge.c:1.16 if_ef.c:1.35
if_ethersubr.c:1.196 if_faith.c:1.37 if_fddisubr.c:1.100 if_fwsubr.c:1.14
if_gif.c:1.54 if_gre.c:1.34 if_iso88025subr.c:1.70 if_loop.c:1.107
if_ppp.c:1.106 if_spppsubr.c:1.121 if_tap.c:1.57 if_tun.c:1.154
if_vlan.c:1.80 ppp_tty.c:1.67 ieee80211_ioctl.c:1.32 atm_if.c:1.31
ng_eiface.c:1.33 ng_ether.c:1.50 ng_fec.c:1.19 ng_iface.c:1.44
ng_sppp.c:1.9 ip_carp.c:1.30 ip_fastfwd.c:1.30 in6.c:1.53 nd6_nbr.c:1.31
natm.c:1.40 if_dc.c:1.162 if_de.c:1.168 if_pcn.c:1.72 if_rl.c:1.154
if_sf.c:1.84 if_sis.c:1.135 if_sk.c:1.108 if_ste.c:1.86 if_ti.c:1.109
if_tl.c:1.101 if_vr.c:1.106 if_wb.c:1.81 if_xl.c:1.194 from HEAD to
RELENG_6:

  Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
  IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
  ifnet.if_drv_flags.  Device drivers are now responsible for
  synchronizing access to these flags, as they are in if_drv_flags.  This
  helps prevent races between the network stack and device driver in
  maintaining the interface flags field.

  Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
  some less so.

  Reviewed by:    pjd, bz

Approved by:	re (scottl)
2005-08-25 05:01:24 +00:00
jhb
d7eebc79f5 Add Giant around linux_getcwd_common() in linux_getcwd().
Approved by:	re (scottl)
2005-07-09 12:34:49 +00:00
jhb
8816876fa9 Add missing locking to linux_connect() so that it can be marked MP safe:
- 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)
2005-07-09 12:26:22 +00:00
jhb
d7828dd231 Fix the computation of uptime for linux_sysinfo(). Before it was returning
the uptime in seconds mod 60 which wasn't very useful.

Approved by:	re (scottl)
2005-07-07 19:17:55 +00:00
pjd
a99a8a69bd Actually only protect mount-point if security.jail.enforce_statfs is set to 2.
If we don't return statistics about requested file systems, system tools
may not work correctly or at all.

Approved by:	re (scottl)
2005-06-23 22:13:29 +00:00
pjd
47f442bcb9 Rename sysctl security.jail.getfsstatroot_only to security.jail.enforce_statfs
and extend its functionality:

value	policy
0	show all mount-points without any restrictions
1	show only mount-points below jail's chroot and show only part of the
	mount-point's path (if jail's chroot directory is /jails/foo and
	mount-point is /jails/foo/usr/home only /usr/home will be shown)
2	show only mount-point where jail's chroot directory is placed.

Default value is 2.

Discussed with:	rwatson
2005-06-09 18:49:19 +00:00
sobomax
307c6bb149 Properly convert FreeBSD priority values into Linux values in the
getpriority(2) syscall.

PR:		kern/81951
Submitted by:	Andriy Gapon <avg@icyb.net.ua>
2005-06-08 20:41:28 +00:00
pjd
311d5e1182 Remove (now) unused argument 'td' from bsd_to_linux_statfs(). 2005-05-27 19:25:39 +00:00
pjd
abf2289872 The code is under '#ifdef not_that_way', but anyway:
- Add missing prison_check_mount() check.
2005-05-22 22:30:31 +00:00
pjd
a6e0e217b2 If we need to hide fsid, kern_statfs()/kern_fstatfs() will do it for us,
so do not duplicate the code in cvtstatfs().
Note, that we now need to clear fsid in freebsd4_getfsstat().

This moves all security related checks from functions like cvtstatfs()
and will allow to add more security related stuff (like statfs(2), etc.
protection for jails) a bit easier.
2005-05-22 21:52:30 +00:00
jeff
f869be5c72 - Pass the ISOPEN flag to namei so filesystems will know we're about to
open them or otherwise access the data.
2005-04-27 09:05:19 +00:00
jeff
afab3762a0 - Change all filesystems and vfs_cache to relock the dvp once the child is
locked in the ISDOTDOT case.  Se vfs_lookup.c r1.79 for details.

Sponsored by:	Isilon Systems, Inc.
2005-04-13 10:59:09 +00:00
mdodd
91ee5f450f Implement SOUND_MIXER_INFO ioctl in compat layer. 2005-04-13 04:33:06 +00:00
mdodd
6f940cf20f Add support for O_NOFOLLOW and O_DIRECT to Linux fcntl() F_GETFL/F_SETFL. 2005-04-13 04:31:43 +00:00
jhb
a3c6b782c3 - Change the vm_mmap() function to accept an objtype_t parameter specifying
the type of object represented by the handle argument.
- Allow vm_mmap() to map device memory via cdev objects in addition to
  vnodes and anonymous memory.  Note that mmaping a cdev directly does not
  currently perform any MAC checks like mapping a vnode does.
- Unbreak the DRM getbufs ioctl by having it call vm_mmap() directly on the
  cdev the ioctl is acting on rather than trying to find a suitable vnode
  to map from.

Reviewed by:	alc, arch@
2005-04-01 20:00:11 +00:00
jeff
bcbda3d771 - Initial cn_lkflags to LK_EXCLUSIVE.
Sponsored by:	Isilon Systems, Inc.
2005-03-29 10:16:12 +00:00
brooks
f16c448930 Use the CTASSERT() macro instead of rolling my own, non-portable one
using #error.

Suggested by:	jhb
2005-03-24 19:26:50 +00:00
brooks
b25337dcb4 Compile errors are way more useful then panics later.
Replace a KASSERT of LINUX_IFNAMSIZ == IFNAMSIZ with a preprocessor
check and #error message.  This will prevent nasty suprises if users
change IFNAMSIZ without updating the linux code appropriatly.
2005-03-24 17:51:15 +00:00
das
fbf7a9b2ee Reject packets larger than IP_MAXPACKET in linux_sendto() for sockets
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
2005-03-23 08:28:00 +00:00
phk
9cea99e06b Neuter the duplicated disk-device magic code for now. Somebody with
serious linux-clue is necessary to fix this properly.
2005-03-15 11:58:40 +00:00
sobomax
b795e2430a Add kernel-only flag MSG_NOSIGNAL to be used in emulation layers to surpress
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
2005-03-08 16:11:41 +00:00
sobomax
a5d845fec6 Handle MSG_NOSIGNAL flag in linux_send() by setting SO_NOSIGPIPE on socket
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
2005-03-07 07:26:42 +00:00
sobomax
f706f4bce8 Handle unimplemented syscall by instantly returning ENOSYS instead of sending
signal first and only then returning ENOSYS to match what real linux does.

PR:		kern/74302
Submitted by:	Travis Poppe <tlp@LiquidX.org>
2005-03-07 00:18:06 +00:00