Commit Graph

1177 Commits

Author SHA1 Message Date
maxv
fcc99ce60e Do not uselessly include <sys/malloc.h>. 2014-11-10 18:46:33 +00:00
maxv
65896a5125 Do not uselessly include <sys/malloc.h>. 2014-11-09 18:08:06 +00:00
christos
0726b418be Maps don't change that frequently between reads, so don't give up and
do what linux does (support reading from an offset).
2014-10-17 20:49:22 +00:00
uebayasi
f62ed0e5b2 Define layerfs as an attribute. 2014-10-12 03:52:30 +00:00
uebayasi
fe9a32c84e Define filesystem attributes with vfs dependency. 2014-10-11 06:42:18 +00:00
christos
ed3aac3c8a The comment about toxicity was correct, restore VNON setting code and
then set the proper type in lookup.
2014-09-05 10:43:26 +00:00
matt
82ef6ef7b8 Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
2014-09-05 09:26:16 +00:00
christos
13ff413336 remove debugging. 2014-09-04 13:29:50 +00:00
christos
e6cf6fbd0d Well, nasty thing happen if you set /dev/tty to VNON too. Disable for now. 2014-09-04 13:28:54 +00:00
christos
5a2111928b Fix type of /dev/tty 2014-09-04 00:30:25 +00:00
maxv
83fce8c371 1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
   probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
   check to ensure they are greater than zero. Since they are used to
   compute the size of two copyin's, a user can control the copied size
   by giving a negative value (like 128-2^29), and thus overwrite kernel
   memory.

Both triggerable from root only.
2014-08-11 14:02:14 +00:00
matt
5918ad3796 #include <sys/cpu.h> 2014-08-10 06:22:06 +00:00
rtr
8cf67cc6d5 split PRU_CONNECT2 & PRU_PURGEIF function out of pr_generic() usrreq
switches and put into separate functions

  - always KASSERT(solocked(so)) even if not implemented
    (for PRU_CONNECT2 only)

  - replace calls to pr_generic() with req = PRU_CONNECT2 with calls to
    pr_connect2()

  - replace calls to pr_generic() with req = PRU_PURGEIF with calls to
    pr_purgeif()

put common code from unp_connect2() (used by unp_connect() into
unp_connect1() and call out to it when needed

patch only briefly reviewed by rmind@
2014-08-09 05:33:00 +00:00
hannken
0ae0e6c566 Change procfs from hashlist to vcache.
- Key is (type, pid, fd)
- Remove argument "p" from procfs_allocvp().  It is only used
  when "type == PFSfd".  Lookup the proc with proc_find() when
  procfs_loadvnode() needs it.
- Use a vfs_vnode_iterator for procfs_revoke_vnodes().
2014-07-27 16:47:26 +00:00
dholland
05d075b3ae Add VOP_FALLOCATE and VOP_FDISCARD to every vnode ops table I can
find.

The filesystem ones all call genfs_eopnotsupp - right now I am only
implementing the plumbing and we can implement fallocate and/or
fdiscard for files later.

The device ones call spec_fallocate (which is also genfs_eopnotsupp)
and spec_fdiscard, which dispatches to the device-level op.

The fifo ones all call vn_fifo_bypass, which also ends up being
EOPNOTSUPP.
2014-07-25 08:20:51 +00:00
dholland
2b17a74d70 Implement spec_fdiscard() using bdev_discard() and cdev_discard().
Also define spec_fallocate() to genfs_eopnotsupp().
2014-07-25 08:19:19 +00:00
hannken
98fe1e89dc Change kernfs from hashlist to vcache. 2014-07-20 13:58:04 +00:00
hannken
73c1268ff3 Remove another KAME IPSEC residue, "struct secasvar" and "struct secpolicy". 2014-07-20 13:17:37 +00:00
hannken
3fd06797df Finish KAME IPSEC removal:
- Remove field kfs_value, it is always zero. Compute the hash from kt_tag.
- Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp.

While here, remove kfs_type from allocvp(), it is always kt->kt_tag.
2014-07-17 08:21:34 +00:00
hannken
3e04c969e3 Change fdesc from hashlist to vcache. 2014-07-13 11:23:01 +00:00
njoly
684c8bf827 Use kproc2 to provide sensible informations for /proc/<pid>/stat. 2014-07-12 09:58:39 +00:00
njoly
7e0ae4d816 Use NZERO instead of hard-coded "20" value. 2014-06-30 14:58:59 +00:00
hannken
3e308cbcef Change field "layerm_tag" to correct type "enum vtagtype".
CID 1216449:  Mixing enum types
2014-05-28 10:51:20 +00:00
hannken
55de4c1831 Change layerfs from hashlist to vcache.
Make VI_LOCKSHARE public again.

Ride 6.99.43
2014-05-25 13:51:25 +00:00
rmind
004d195aec fifo_open: assign v_fifoinfo once initialised; add an assert while here. 2014-05-17 23:30:24 +00:00
maxv
23f76b6d00 An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
2014-04-16 18:55:17 +00:00
christos
79c480ed3b From Ilya Zykov: Unbreak kernfs which was broken by this commit
|Make the spec_node table implementation private to spec_vnops.c.
|To retrieve a spec_node, two new lookup functions (by device or by mount)
|are implemented.  Both return a referenced vnode, for an opened block device
|the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
|will not fire.  Otherwise any vnode matching the criteria gets returned.
|No objections on tech-kern.

The effect was that ls /kernfs appeared empty in most cases.
2014-04-08 17:56:10 +00:00
christos
16c9d42fcd On my 24 proc box I got ENOSPC, so make the routine return the size it wants
and try again.
2014-04-05 18:42:32 +00:00
hannken
f3cf481632 - Make VI_XLOCK, VI_CLEAN and VI_LOCKSHARE private to kern/vfs_*.c.
- Make vwait() static.
- Add  vdead_check() to check a vnode for being or becoming dead.

Discussed on tech-kern.

Welcome to 6.99.38
2014-03-24 13:42:40 +00:00
hannken
6d285189fb Change all vfsops to use C99 designated initializers.
No functional changes intended.
2014-03-23 15:21:15 +00:00
christos
13a17f1494 kill sprintf 2014-03-20 18:01:19 +00:00
riastradh
6cb10275d0 Merge riastradh-drm2 to HEAD. 2014-03-18 18:20:35 +00:00
hannken
a8b05c0ddf Restructure layer_lock() to always lock before testing for dead node.
Use ISSET() to test flags, add assertions.
2014-03-12 09:39:23 +00:00
hannken
031631b85f Restructure genfs_deadlock() and genfs_lock() to always lock before
testing for dead node.  Use ISSET() to test flags, add assertions.

Save the mount for fstrans_done() before genfs_unlock() unlocks the node.
2014-03-12 09:38:51 +00:00
hannken
2b6ec89863 The current implementation of vn_lock() is racy. Modification of
the vnode operations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

- Pass down LK_RETRY to the lock operation (hint for deadfs only).

- Change deadfs lock operation to return ENOENT if LK_RETRY is unset.

- Change all other lock operations to check for dead vnode once
  the vnode is locked and unlock and return ENOENT in this case.

With these changes in place vnode lock operations will never succeed
after vclean() has marked the vnode as VI_XLOCK and before vclean()
has changed the operations vector.

Adresses PR kern/37706 (Forced unmount of file systems is unsafe)

Discussed on tech-kern.

Welcome to 6.99.33
2014-02-27 16:51:37 +00:00
hannken
d940ddcc62 Currently dead vnodes still reside on the vnodelist of the file system
they have been removed from.

Create a "dead mount" that takes dead vnodes until they get freed.

Discussed on tech-kern.
2014-02-27 13:00:06 +00:00
pooka
4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
hannken
8653615804 Change layerfs_vget(), layerfs_fhtovp() and the various layer xxx_mount()
functions to unlock/relock the node for the call to layer_node_create().

Finally remove dirty hacks (LK_NOWAIT, kpause) from layer_node_find().
2014-02-10 11:23:14 +00:00
hannken
c95ccd223d Adjust comment and change vput() to vrele(). This change got missed
when changing vnode creation operations to return unlocked result.
2014-02-09 17:18:38 +00:00
hannken
ad55c847dd When layer_node_alloc() finds another thread already inserted the node
into the hashlist and discards the now unneeded node it will raise a
panic "dead but not clean".

Reorder the initialization and use ungetnewvnode() to discard the node.
2014-02-09 17:15:51 +00:00
hannken
97834f7ba0 Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@

Welcome to 6.99.31
2014-02-07 15:29:20 +00:00
hannken
59e42c388a Move fstrans_start()/fstrans_done() into genfs_insane_rename() to protect
the complete rename operation like we do for all other vnode operations.
2014-02-06 10:57:12 +00:00
hannken
2ea0d9f22a Allow layer_node_create() with unlocked lower node and change
layer_bypass() to enter nodes from creation operations unlocked.
2014-01-29 08:27:04 +00:00
hannken
04c776e5c8 Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
2014-01-23 10:13:55 +00:00
hannken
1139274440 Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
2014-01-17 10:55:01 +00:00
christos
9d605174d9 Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
2013-11-27 17:24:43 +00:00
christos
0b725b63c7 change the mountlist CIRCLEQ into a TAILQ 2013-11-23 13:35:36 +00:00
hannken
65bcb93b31 Add missing operations that unlock or dereference their arguments.
Stop checking for a vnode state change -- dead vnodes never change state.
2013-11-07 09:45:53 +00:00
hannken
65b1f85ab6 Vnode API cleanup pass 1.
- Make these defines and functions private to vfs_vnode.c:

  VC_MASK, VC_LOCK, DOCLOSE, VI_IANCTREDO and VI_INACTNOW
  vclean() and vrelel()

- Remove the long time unused lwp argument from vrecycle().

- Remove vtryget(), it is responsible for ugly hacks and doesn't
  look that effective.

Presented on tech-kern.

Welcome to 6.99.25
2013-10-29 09:53:51 +00:00
martin
6a2419fedf Turn a few __unused into __diagused 2013-10-25 11:35:55 +00:00