1745 Commits

Author SHA1 Message Date
rwatson
5bb071d425 MFC devfs_rule.c:1.21 from HEAD to RELENG_6:
When returning EIO from DEVFSIO_RADD ioctl, drop the exclusive rule
  lock.  Otherwise the system comes to a rather sudden and grinding
  halt.

As the underlying devfs locking changes that lead to this bug have not
been merged to RELENG_5, this fix to those locking changes does not
need to be merged.
2006-01-11 10:15:57 +00:00
maxim
ffe68f436b MFC rev. 1.41: typo fix. 2006-01-08 20:28:48 +00:00
dwhite
16e12cca71 MFC:
src/sys/fs/devfs/devfs_vnops.c		1.128
 src/sys/kern/vfs_subr.c		1.652

This is a workaround for a complicated issue involving VFS cookies and devfs.
The PR and patch have the details. The ultimate fix requires architectural
changes and clarifications to the VFS API, but this will prevent the system
from panicking when someone does "ls /dev" while running in a shell under the
linuxulator.

PR:		88249
Submitted by:   "Devon H. O'Dell" <dodell@ixsystems.com>
2005-11-12 21:21:27 +00:00
kris
2eda86bb49 MFC 1.73:
Reflect mpsafety of the underlying filesystem in the nullfs image.

Approved by:	re (scottl)
2005-10-25 20:33:31 +00:00
phk
484eb21391 MFC:
Use correct criteria to determine if dirent can be removed
	right away.

Approved by:	re@ (scottl)
2005-10-19 21:25:31 +00:00
truckman
ac3fe75ffe MFC nwfs_vnops.c 1.42
Original commit message:
  Modified files:
    sys/fs/nwfs          nwfs_vnops.c
  Log:
  Update nwfs_lookup() to match the current cache_lookup() API.
  cache_lookup() has returned a ref'ed and locked vnode since
  vfs_cache.c:1.96, dated Tue Mar 29 12:59:06 2005 UTC.  This change
  is similar to the change made to smbfs_lookup() in smbfs_vnops.c:1.58.

  Tested by:      "Antony Mawer" ant AT mawer.org
  MFC after:      2 weeks

  Revision  Changes    Path
  1.42      +11 -26    src/sys/fs/nwfs/nwfs_vnops.c

Approved by:	re (scottl)
2005-10-19 20:18:44 +00:00
delphij
24b61ed7a8 MFC (by des)
| Eliminate an unnecessary bcopy().
|
| Revision  Changes    Path
| 1.57      +15 -15    src/sys/fs/pseudofs/pseudofs_vnops.c

Approved by:	re (scottl)
No objection:	des
2005-10-09 08:59:34 +00:00
delphij
7c26851aa1 MFC (by obrien)
| Ensure the full value is written into inode variables.
|
| PR:             85503
| Submitted by:   Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
|
| Revision  Changes    Path
| 1.89      +2 -2      src/sys/fs/msdosfs/msdosfs_denode.c

Approved by:	re (scottl)
2005-10-09 03:33:52 +00:00
rwatson
70be888bba Merge fifo_vnops.c:1.132 from HEAD to RELENG_6:
Second attempt at a work-around for fifo-related socket panics during
  make -j with high levels of parallelism: acquire Giant in fifo I/O
  routines.

  Discussed with: ups

Approved by:	re (scottl)
2005-10-04 15:33:06 +00:00
peadar
5f354c9a11 MFC BOOTSIG[23] removal:
msdosfs_vfsops.c v1.146
    bootsect.h v1.13

    Remove checks for BOOTSIG[23] from FAT32 bootblocks.
    There seems to be very little documentary evidence outside this
    implementation to suggest a these checks are neccessary, and more
    than one camera-formatted flash disk fails the check, but mounts
    successfully on most other systems.

Approved by: re (scottl@)
2005-10-04 13:13:57 +00:00
rwatson
f58713cf53 Merge fifo_vnops.c:1.130 from HEAD to RELENG_6:
Assert v_fifoinfo is non-NULL in fifo_close() in order to catch
  non-conforming cases sooner.

  Reported by:    Peter Holm <peter at holm dot cc>

Approved by:	re (scottl)
2005-10-02 10:07:21 +00:00
phk
d1a2719799 MFC:
one character fix in mount option name.

Approved by:	re@ (scottl)
2005-10-01 17:39:50 +00:00
delphij
15d6d1b68d MFC sys/fs/hpfs/hpfs_vfsops.c:1.54-1.56,
sys/fs/msdosfs/msdosfs_vfsops.c:1.145,
    sys/fs/ntfs/ntfs_vfsops.c:1.79-1.80,
    sys/fs/udf/udf_vfsops.c:1.34-1.35,
    sys/gnu/fs/ext2fs/ext2_vfsops.c:1.152-1.153,
    sys/gnu/fs/reiserfs/reiserfs_vfsops.c:1.2-1.3 (by ssouhlal):

*_mountfs() (if the filesystem mounts from a device) needs devvp to be
locked, so lock it.

Approved by:	re (scottl)
2005-09-30 06:26:42 +00:00
rwatson
14efd49e2f Merge fifo_vnops.c:1.129 from HEAD to RELENG_6:
Lock the read socket receive buffer when frobbing the sb_state flag on
  that socket during open, not the write socket receive buffer.

  Spotted by:	ups

Approved by:	re (scottl)
2005-09-28 06:55:02 +00:00
rwatson
442db0620a Merge fifo_vnops.c:1.128 from HEAD to RELENG_6:
For reasons of consistency (and necessity), assert an exclusive vnode
  lock on the fifo vnode in fifo_open(): we rely on the vnode lock to
  serialize access to v_fifoinfo.

Approved by:	re (scottl)
2005-09-28 06:47:32 +00:00
phk
6c1584f5fc MFC:
DEVFS fixes of many sorts.

Approved by:	re@ (scottl)
2005-09-26 14:36:54 +00:00
rwatson
533efa352a Merge fifo_vnops.c:1.126 from HEAD to RELENG_6:
Assert that (vp) is locked in fifo_close(), since we rely on the
  exclusive vnode lock to synchronize the reference counts on struct
  fifoinfo.

Approved by:	re (scottl)
2005-09-21 15:31:26 +00:00
rwatson
d14a3e32b7 Merge fifo_vnops.c:1.125 from HEAD to RELENG_6:
The socket pointers in fifoinfo are not permitted to be NULL, so
  don't check if they are, it just confuses the fifo code more.

Approved by:	re (kensmith)
2005-09-20 13:57:17 +00:00
phk
051ea6d1a8 MFC:
Various fixes for DEVFS, in particular "devfs ruleset already running".

Approved by:	re@ (scottl)
2005-09-18 07:10:57 +00:00
delphij
80a9b1b6e7 Oops, actually MFC 1.89 (by kan) which was missed in previous commit:
Handle a race condition where NULLFS vnode can be cleaned while threads
can still be asleep waiting for lowervp lock.

Tested by:	kkenn
Discussed with: ssouhlal, jeffr

(this is an early MFC for inclusion in the upcoming 6.0-BETA5)

Approved by:	re (scottl)
2005-09-17 15:51:41 +00:00
delphij
691b9ef2ea MFC 1.88 (by ssouhlal):
Use vput() instead of vrele() in null_reclaim() since the lower vnode
is locked.

MFC 1.89 (by kan):

Handle a race condition where NULLFS vnode can be cleaned while threads
can still be asleep waiting for lowervp lock.

Tested by:	kkenn
Discussed with: ssouhlal, jeffr

(rev. 1.89 is an early MFC for inclusion in the upcoming 6.0-BETA5)

Approved by:	re (scottl)
2005-09-17 15:48:05 +00:00
rwatson
f32e67ff68 Merge fifo_vnops.c:1.124 from HEAD to RELENG_6:
Trim down now (believed to be) unused fifo_ioctl() and
  fifo_kqfilter() VOP implementations, since they in theory are used
  only on open file descriptors, in which case the ioctls are via
  fifo_ioctl_f() and kqueue requests are via fifo_kqfilter_f().
  Generate warnings if they are entered for now.  These printf()
  calls should become panic() calls.

  Annotate and re-implement fifo_ioctl_f(): don't arbitrarily
  forward ioctls to the socket layer, only forward the ones we
  explicitly support for fifos.  In the case of FIONREAD, don't
  forward the request to the write socket on a read-write fifo, or
  the read result is overwritten.  Annotate a nasty case for the
  undefined POSIX O_RDWR on fifos, in which failure of the second
  ioctl will result in the socket pair being in an inconsistent
  state.

  Assert copyright as I find myself rewriting non-trivial parts of
  fifofs.

Approved by:	re (scottl)
2005-09-16 14:03:57 +00:00
rwatson
ae28f5cb27 Merge fifo_vnops.c:1.122 from HEAD to RELENG_6:
Annotate two issues:

  1) fifo_kqfilter() is not actually ever used, it likely should be GC'd.

  2) fifo_kqfilter_f() doesn't implement EVFILT_VNODE, so detecting events
     on the underlying vnode for a fifo no longer works (it did in 4.x).
     Likely, fifo_kqfilter_f() should forward the request to the VFS using
     fp->f_vnode, which would work once fifo_kqfilter() was detached from
     the vnode operation vector (removing the fifo override).

  Discussed with: phk

Approved by:	re (scottl)
2005-09-16 14:03:10 +00:00
rwatson
f254bafe68 Merge fifo_vnops.c:1.123 from HEAD to RELENG_6:
As a result of kqueue locking work, socket buffer locks will always
  be held when entering a kqueue filter for fifos via a socket buffer
  event: as such, assert the lock unconditionally rather than acquiring
  it conditionally.

Approved by:	re (scottl)
2005-09-16 13:36:44 +00:00
rwatson
504a02736d Merge fifo_vnops.c:1.121 from HEAD to RELENG_6:
Introduce no-op nosup fifo kqueue filter and detach routine, which are
  used when a read filter is requested on a write-only fifo descriptor, or
  a write filter is requested on a read-only fifo descriptor.  This
  permits the filters to be registered, but never raises the event, which
  causes kqueue behavior for fifos to more closely match similar semantics
  for poll and select, which permit testing for the condition even though
  the condition will never be raised, and is consistent with POSIX's notion
  that a fifo has identical semantics to a one-way IPC channel created
  using pipe() on most operating systems.

  The fifo regression test suite can now run to completion on HEAD without
  errors.

Approved by:	re (kensmith)
2005-09-15 20:53:56 +00:00
rwatson
6a6cd36b7c Merge fifo_vnops.c:1.120 from HEAD to RELENG_6:
When a request is made to register a filter on a fifo that doesn't
  apply to the fifo (i.e., not EVFILT_READ or EVFILT_WRITE), reject
  it as EINVAL, not by returning 1 (EPERM).

Approved by:	re (kensmith)
2005-09-15 20:50:31 +00:00
rwatson
6185980a8f Merge fifo_vnops.c:1.119 from HEAD to RELENG_6:
Remove DFLAG_SEEKABLE from fifo file descriptors: fifos are not seekable
  according to POSIX, not to mention the fact that it doesn't make sense
  (and hence isn't really implemented).  This causes the fifo_misc
  regression test to succeed.

Approved by:	re (scottl)
2005-09-15 20:50:04 +00:00
rwatson
dcebacb956 Merge fifo_vnops.c:1.118 from HEAD to RELENG_6:
Only poll the fifo for read events if the fifo is attached to a readable
  file descriptor.  Otherwise, the read end of a fifo might return that it
  is writable (which it isn't).

  Only poll the fifo for write events if the fifo attached to a writable
  file descriptor.  Otherwise, the write end of a fifo might return that
  it is readable (which it isn't).

  In the event that a file is FREAD|FWRITE (which is allowed by POSIX, but
  has undefined behavior), we poll for both.

Approved by:	re (kensmith)
2005-09-15 20:28:56 +00:00
rwatson
8c6b46594b Merge fifo_vnops.c:1.117 from HEAD to RELENG_6:
After going to some trouble to identify only the write-related events
  to poll the write socket for, the fifo polling code proceeded to poll
  for the complete set of events.  Use 'levents' instead of 'events' as
  the argument to poll, and only poll the write socket if there is
  interest in write events.

Approved by:	re (kensmith)
2005-09-15 20:28:27 +00:00
rwatson
5e1c31f370 Merge fifo_vnops.c:1.116 from HEAD to RELENG_6:
When a writer opens a fifo, wake up the read socket for read, not the
  write socket.

Approved by:	re (kensmith)
2005-09-15 20:27:56 +00:00
rwatson
7881b52021 Merge fifo_vnops.c:1.115 from HEAD to RELENG_6:
Add an assertion that fifo_open() doesn't race against other threads
  while sleeping to allocate fifo state: due to using the vnode lock to
  serialize access to a fifo during open, it shouldn't happen (tm).

Approved by:	re (kensmith)
2005-09-15 20:27:25 +00:00
rwatson
2c116f6385 Merge fifo_vnops.c:1.114 from HEAD to RELENG_6:
Rather than reaching into the internals of the UNIX domain socket code
  by calling uipc_connect2() to connect two socket endpoints to create a
  fifo, call soconnect2().

Approved by:    re (kensmith)
2005-09-15 20:26:19 +00:00
phk
10e72d987a MFC:
missing dev_relthread() call.

Approved by:	re@ (scottl)
2005-09-05 11:02:30 +00:00
cvs2svn
42fe58c4c6 This commit was manufactured by cvs2svn to create branch 'RELENG_6'. 2005-08-16 19:08:02 +00:00
rwatson
71a8cbcb20 Merge two sets of changes relating to devfs device node cloning from
HEAD to RELENG_6: changes to introduce a credentialed version of the
clone event handler, and then changes to merge the regular and
credentialed versions into a single interface (along with updates to
existing consumers).  With this merge, 6.x and 7.x are in sync.

First batch merges devfs_devs.c:1.37, devfs_vnops.c:1.115,
kern_conf.c:1.187, tty_pty.c:1.138, mac_vfs.c:1.109, mac_biba.c:1.36,
mac_lomac.c:1.36, mac_mls.c:1.73, mac_stub.c:1.53, mac_test.c:1.61,
conf.h:1.223, mac.h:1.68, mac_policy.h:1.67 from HEAD to RELENG_6:

  When devfs cloning takes place, provide access to the credential of the
  process that caused the clone event to take place for the device driver
  creating the device.  This allows cloned device drivers to adapt the
  device node based on security aspects of the process, such as the uid,
  gid, and MAC label.

  - Add a cred reference to struct cdev, so that when a device node is
    instantiated as a vnode, the cloning credential can be exposed to
    MAC.

  - Add make_dev_cred(), a version of make_dev() that additionally
    accepts the credential to stick in the struct cdev.  Implement it and
    make_dev() in terms of a back-end make_dev_credv().

  - Add a new event handler, dev_clone_cred, which can be registered to
    receive the credential instead of dev_clone, if desired.

  - Modify the MAC entry point mac_create_devfs_device() to accept an
    optional credential pointer (may be NULL), so that MAC policies can
    inspect and act on the label or other elements of the credential
    when initializing the skeleton device protections.

  - Modify tty_pty.c to register clone_dev_cred and invoke make_dev_cred(),
    so that the pty clone credential is exposed to the MAC Framework.

  While currently primarily focussed on MAC policies, this change is also
  a prerequisite for changes to allow ptys to be instantiated with the UID
  of the process looking up the pty.  This requires further changes to the
  pty driver -- in particular, to immediately recycle pty nodes on last
  close so that the credential-related state can be recreated on next
  lookup.

  Submitted by:   Andrew Reisse <andrew.reisse@sparta.com>
  Obtained from:  TrustedBSD Project
  Sponsored by:   SPAWAR, SPARTA

Second batch merges scsi_target.c:1.68, coda_fbsd.c:1.43,
firewirereg.h:1.38, fwdev.c:1.47, nmdm.c:1.36, snp.c:1.100, dsp.c:1.82,
mixer.c:1.45, vkbd.c:1.9, devfs_vnops.c:1.117, tty_pty.c:1.139,
tty_tty.c:1.57, bpf.c:1.156, if_tap.c:1.56, if_tun.c:1.153,
smb_dev.c:1.28, conf.h:1.224 from HEAD to RELENG_6:

  Merge the dev_clone and dev_clone_cred event handlers into a single
  event handler, dev_clone, which accepts a credential argument.
  Implementors of the event can ignore it if they're not interested,
  and most do.  This avoids having multiple event handler types and
  fall-back/precedence logic in devfs.

  This changes the kernel API for /dev cloning, and may affect third
  party packages containg cloning kernel modules.

  Requested by:   phk

These changes modifies the kernel device driver API for device cloning,
and might require minor modifications to third party device drivers that
make use of devfs cloning.  It will not be merged to RELENG_5.

Approved by:	re (scottl)
2005-08-13 21:24:18 +00:00
kris
1412ec26bf MFC:
>  devfs is not yet fully MPSAFE - for example, multiple concurrent devfs(8)
>  processes can cause a panic when operating on rulesets.

Approved by:	re (scottl)
2005-07-29 23:21:23 +00:00
imura
99200c85ff MFC 1.45: Fix looking up files having invalid short name.
PR:		77074
Approved by:	re (kensmith)
2005-07-23 17:02:04 +00:00
simon
777ee0c901 MFC rev 1.116 of src/sys/fs/devfs/devfs_vnops.c:
Correct devfs ruleset bypass.

Submitted by:	csjp
Reviewed by:	phk
Security:	FreeBSD-SA-05:17.devfs
Approved by:	re (scottl)
2005-07-20 13:35:07 +00:00
cvs2svn
dd2adf2c10 This commit was manufactured by cvs2svn to create branch 'RELENG_6'. 2005-07-11 04:14:43 +00:00
tanimura
f03d3eb58c Regrab dvp only when ISDOTDOT.
Approved by:	re (scottl)
2005-07-09 13:52:49 +00:00
jeff
0d69457df8 - Since we don't hold a usecount in pfs_exit we have to get a holdcnt
prior to calling vgone() to prevent any races.

Sponsored by:	Isilon Systems, Inc.
Approved by:	re (vfs blanket)
2005-07-07 07:33:10 +00:00
peter
921b3c5ee4 Jumbo-commit to enhance 32 bit application support on 64 bit kernels.
This is good enough to be able to run a RELENG_4 gdb binary against
a RELENG_4 application, along with various other tools (eg: 4.x gcore).
We use this at work.

ia32_reg.[ch]: handle the 32 bit register file format, used by ptrace,
	procfs and core dumps.
procfs_*regs.c: vary the format of proc/XXX/*regs depending on the client
	and target application.
procfs_map.c: Don't print a 64 bit value to 32 bit consumers, or their
	sscanf fails.  They expect an unsigned long.
imgact_elf.c: produce a valid 32 bit coredump for 32 bit apps.
sys_process.c: handle 32 bit consumers debugging 32 bit targets.  Note
	that 64 bit consumers can still debug 32 bit targets.

IA64 has got stubs for ia32_reg.c.

Known limitations: a 5.x/6.x gdb uses get/setcontext(), which isn't
implemented in the 32/64 wrapper yet.  We also make a tiny patch to
gdb pacify it over conflicting formats of ld-elf.so.1.

Approved by:	re
2005-06-30 07:49:22 +00:00
peter
2778435f72 Conditionally weaken sys_generic.c rev 1.136 to allow certain dubious
ioctl numbers in backwards compatability mode.  eg: an IOC_IN ioctl with
a size of zero.  Traditionally this was what you did before IOC_VOID
existed, and we had some established users of this in the tree, namely
procfs.  Certain 3rd party drivers with binary userland components also
have this too.

This is necessary to have 4.x and 5.x binaries use these ioctl's.  We
found this at work when trying to run 4.x binaries.

Approved by:	re
2005-06-30 00:19:08 +00:00
imura
5809391d17 Avoid casting from (int *) to (size_t *) in order to fix udf_iconv on amd64.
Reviewed by:	scottl
MFC after:	2 weeks
2005-06-05 02:09:48 +00:00
rodrigc
dba46a3ce7 Do not declare a struct as extern, and then implement
it as static in the same file.  This is not legal C,
and GCC 4.0 will issue an error.

Reviewed by:	phk
Approved by:	das (mentor)
2005-05-31 14:50:49 +00:00
brueffer
7bc989441b Fix three typos in comments. Two of them obtained from OpenBSD.
MFC after:	3 days
2005-05-11 21:10:35 +00:00
kan
3f8ab6c93f Do not dereference dvp pointer before doing a NULL check.
Noticed by: Coverity Prevent analysis tool.
2005-05-11 19:08:38 +00:00
anholt
b6be180393 Staticize a symbol used only in this file.
PR:		kern/43613
Submitted by:	Matt Emmerton, matt at gsicomp dot on dot ca
2005-05-06 20:47:09 +00:00
robert
38711d8dea The printf(9) `%p' conversion specifier puts an "0x" in
front of the pointer value.  Therefore, remove the "0x"
from the format string.
2005-05-06 00:15:57 +00:00
robert
46abb4815c Fix our NTFS readdir function.
To check a directory's in-use bitmap bit by bit, we use
a pointer to an 8 bit wide unsigned value.

The index used to dereference this pointer is calculated
by shifting the bit index right 3 bits.  Then we do a
logical AND with the bit# represented by the lower 3
bits of the bit index.

This is an idiomatic way of iterating through a bit map
with simple bitwise operations.

This commit fixes the bug that we only checked bits
3:0 of each 8 bit chunk, because we only used bits 1:0
of the bit index for the bit# in the current 8 bit value.
This resulted in files not being returned by getdirentries(2).

Change the type of the bit map pointer from `char *' to
`u_int8_t *'.
2005-05-06 00:06:06 +00:00