13664 Commits

Author SHA1 Message Date
rpaulo
7c72adbd8f MFC r269408, r269409:
shm_open()/shm_unlink() ktrace support.
2014-08-08 22:08:51 +00:00
kib
efd262c8d0 MFC r269244:
Remove one-time use macros which check for the vnode lifecycle.
2014-08-05 05:00:22 +00:00
kib
db3e0174c3 MFC r269190:
For md(4), posix shm(3) and tmpfs(5), free swap space used by paged in
dirty page, which is written by the process.
2014-08-04 01:14:27 +00:00
peter
5cebaadbe0 Insta-MFC r269489: partial revert of r262867 which was MFC'ed as r263820.
Don't ignore sndbuf/rcvbuf limits for SOCK_DGRAM sockets.  This appears
to be an edit error or patch fuzz mismatch.
2014-08-03 22:59:47 +00:00
hselasky
ad96ca7b3d Partial MFC of r267961, r267973, r267985, r267992, r267993 and r268005:
Backport some macro definitions to make backporting code from FreeBSD
current easier.
2014-08-02 20:58:46 +00:00
truckman
d1eb948ff0 MFC r268780
Nuke the never-used RF_TIMESHARE feature, reducing the complexity of the
code.  The consensus on arch@ is that this feature might have been useful
in the distant past, but is now just unnecessary bloat.

The int_rman_activate_resource() and int_rman_deactivate_resource()
functions become trivial, so manually inline them.

The special deferred handling of RF_ACTIVE is no longer needed in
reserve_resource_bound(), so eliminate the associated code at the
end of the function.

These changes reduce the object file size by more than 500 bytes on i386.

Update the rman.9 man page to reflect the removal of the RF_TIMESHARE
feature.
2014-08-01 15:04:46 +00:00
kib
270336f678 MFC r269205:
Simplify the expression.
2014-08-01 04:05:13 +00:00
kib
4af1d57b25 MFC r268764:
Check for the cross-device cross-link attempt in the VFS, instead of
VOP_LINK() implemenations.
2014-07-30 03:56:17 +00:00
kib
36fc0d1d01 MFC r268612:
Add helper helper vfs_write_suspend_umnt().

Fix the bug in the FFS unmount, when suspension failed, the ufs
extattrs were not reinitialized.
2014-07-28 01:11:29 +00:00
kib
e0e54a97de MFC r268607:
In kern_linkat(), avoid passing doomed vnode to the VOP.
2014-07-28 00:57:28 +00:00
kib
49b4c6d03e MFC r268606:
Generalize vn_get_ino() to allow filesystems to use custom vnode
producer. Convert inline copies of vn_get_ino() in msdosfs and cd9660
into the uses of vn_get_ino_gen().
2014-07-28 00:53:26 +00:00
kib
59960de643 MFC r268466:
Calculate the amount of resident pages by looking in the objects chain
backing the region. Add a knob to disable the residency calculation at
all.

MFC r268490:
Unconditionally initialize addr to handle the case of changed map
timestamp while the map is unlocked.

MFC r268711:
Change the calculation of the kinfo_vmentry field kve_private_resident
to reflect its name.

MFC r268712:
Followup to r268466.
- Move the code to calculate resident count into separate function.
  It reduces the indent level and makes the operation of
  vmmap_skip_res_cnt tunable more clear.
- Optimize the calculation of the resident page count for map entry.
  Skip directly to the next lowest available index and page among the
  whole shadow chain.
- Restore the use of pmap_incore(9), only to verify that current
  mapping is indeed superpage.
- Note the issue with the invalid pages.
2014-07-24 16:33:29 +00:00
kib
8d73e435bf MFC r268384:
When the lock was stolen from us, retry the whole lock sequence in kernel,
instead of returning EINTR.
2014-07-24 10:43:15 +00:00
kevlo
f112206e5a MFC r268787:
Deprecate m_act.  Use m_nextpkt always.
2014-07-24 06:02:03 +00:00
kevlo
771984715d MFC r268601:
Make bind(2) and connect(2) return EAFNOSUPPORT for AF_UNIX on wrong
address family.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191586 for the
original discussion.

Reviewed by:	terry
2014-07-24 05:57:33 +00:00
truckman
287461bc52 MFC r268373
Declaration whitespace changes for style(9).
2014-07-17 23:49:01 +00:00
kib
eb437edaac MFC r268211:
Micro-manage clang to get the expected inlining for cpu_search().
2014-07-10 09:08:02 +00:00
delphij
7642e9504a Fix kernel memory disclosure in control message and SCTP notifications.
Security:	FreeBSD-SA-14:17.kmem
Security:	CVE-2014-3952, CVE-2014-3953
2014-07-08 21:54:50 +00:00
ray
74b8e10dc8 267622 Log:
Rename vt(4) vga module to dismiss interference with syscons(4) vga module.
267623 Log:
  Remove stale link to deleted vt(4) xboxfb driver.
267624 Log:
  syscons(4) and vt(4) can be built together now.
267625 Log:
  Allow to disable syscons(4) if "hw.syscons.disable" kenv is set.
267626 Log:
  Suspend vt(4) initialization if "kern.vt.disable" kenv is set.
267965 by emaste@ Log:
  Use a common tunable to choose between vt(4)/sc(4)
  With this change and previous work from ray@ it will be possible to put
  both in GENERIC, and have one enabled by default, but allow the other to
  be selected via the loader.
  (The previous implementation had separate kern.vt.disable and
  hw.syscons.disable tunables, and would panic if both drivers were
  compiled in and neither was explicitly disabled.)
268175 by emaste@ Log:
  Fix vt(4) detection in kbdcontrol and vidcontrol
  As sc(4) and vt(4) coexist and are both enabled in GENERIC, the existence
  of a vt(4) sysctl is not sufficient to determine that vt(4) is in use.
  Reported by:  Trond Endrestøl
268045 by emaste@ Log:
  Add vt(4) to GENERIC and retire the separate VT config
  vt(4) and sc(4) can now coexist in the same kernel.  To choose the vt
  driver, set the loader tunable kern.vty=vt .

Sponsored by:	The FreeBSD Foundation
2014-07-07 14:16:05 +00:00
mjg
d74df80505 MFC r268002:
Call fdcloseexec right after fdunshare.

No functional changes.
2014-07-06 23:27:13 +00:00
mjg
302b3764d6 MFC r268001:
Make fdunshare accept only td parameter.

Proc had to match the thread anyway and 2 parameters were inconsistent
with the rest.
2014-07-06 23:23:01 +00:00
mjg
63523f9ee1 MFC r268000:
Make sure to always clear p_fd for process getting rid of its filetable.

Filetable can be shared with other processes. Previous code failed to
clear the pointer for all but the last process getting rid of the table.
This is mostly cosmetics.

Get rid of 'This should happen earlier' comment. Clearing the pointer in
this place is fine as consumers can reliably check for files availability
by inspecting fd_refcnt and vnodes availabity by NULL-checking them.
2014-07-06 23:20:48 +00:00
mjg
12766f2ff4 MFC r267947:
Check lower bound of cmsg_len.

If passed cm->cmsg_len was below cmsghdr size the experssion:
datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data;

would give negative result. However, in practice it would not
result in a crash because the kernel would try to obtain garbage fds
for given process and would error out with EBADF.

PR:		124908
Submitted by:	campbell mumble.net (modified a little)
2014-07-06 23:01:29 +00:00
mjg
134eeca755 MFC r267760:
Tidy up fd-related functions called by do_execve

o assert in each one that fdp is not shared
o remove unnecessary NULL checks - all userspace processes have fdtables
and kernel processes cannot execve
o remove comments about the danger of fd_ofiles getting reallocated - fdtable
is not shared and fd_ofiles could be only reallocated if new fd was about to be
added, but if that was possible the code would already be buggy as setugidsafety
work could be undone
2014-07-06 22:58:53 +00:00
mjg
c9bb8da011 MFC r267755:
Don't take filedesc lock in fdunshare().

We can read refcnt safely and only care if it is equal to 1.

If it could suddenly change from 1 to something bigger the code would be
buggy even in the previous form and transitions from > 1 to 1 are equally racy
and harmless (we copy even though there is no need).
2014-07-06 22:56:34 +00:00
mjg
4ec4a65855 MFC r267710:
fd: replace fd_nfiles with fd_lastfile where appropriate

fd_lastfile is guaranteed to be the biggest open fd, so when the intent
is to iterate over active fds or lookup one, there is no point in looking
beyond that limit.

Few places are left unpatched for now.
2014-07-06 22:54:17 +00:00
mjg
bfa18e4663 MFC r267708:
do_dup: plug redundant adjustment of fd_lastfile

By that time it was already set by fdalloc, or was there in the first place
if fd is replaced.
2014-07-06 22:51:53 +00:00
mjg
aa97fde7f4 MFC r265247:
Request a non-exiting process in sysctl_kern_proc_{o,}filedesc

This fixes a race with exit1 freeing p_textvp.
2014-07-06 22:49:07 +00:00
mjg
4c78be8a98 MFC r265206:
Ignore the error from pipespace_new when creating a pipe.

It can fail if pipe map is exhausted (as a result of too many pipes created),
but it is not fatal and could be provoked by unprivileged users. The only
consequence is worse performance with given pipe.
2014-07-06 22:47:18 +00:00
truckman
eca942517b MFC r266814
Initialize r_flags the same way in all cases using a sanitized copy of
flags that has several bits cleared. The RF_WANTED and RF_FIRSTSHARE
bits are invalid in this context, and we want to defer setting RF_ACTIVE
in r_flags until later.  This should make rman_get_flags() return
the correct answer in all cases.

Add a KASSERT() to catch callers which incorrectly pass the RF_WANTED
or RF_FIRSTSHARE flags.

Do a strict equality check on the share type bits of flags.  In
particular, do an equality check on RF_PREFETCHABLE.  The previous
code would allow one type of mismatch of RF_PREFETCHABLE but disallow
the other type of mismatch.  Also, ignore the the RF_ALIGNMENT_MASK
bits since alignment validity should be handled by the amask check.
This field contains an integer value, but previous code did a strange
bitwise comparison on it.

Leave the original value of flags unmolested as a minor debug aid.

Change the start+amask overflow check to a KASSERT() since it is just
meant to catch a highly unlikely programming error in the caller.

Reviewed by:	jhb
2014-07-02 17:32:43 +00:00
marius
618ac05759 MFC: r267978
In order to get vt(4) a bit closer to the feature set provided by sc(4),
implement options TERMINAL_{KERN,NORM}_ATTR. These are aliased to
SC_{KERNEL_CONS,NORM}_ATTR and like these latter, allow to change the
default colors of normal and kernel text respectively.
Note on the naming: Although affecting the output of vt(4), technically
kern/subr_terminal.c is primarily concerned with changing default colors
so it would be inconsistent to term these options VT_{KERN,NORM}_ATTR.
Actually, if the architecture and abstraction of terminal+teken+vt would
be perfect, dev/vt/* wouldn't be touched by this commit at all.

Reviewed by:	emaste
Sponsored by:	Bally Wulff Games & Entertainment GmbH
2014-06-30 09:59:23 +00:00
kib
fa905b5ead MFC r267491:
Use vn_io_fault for the writes from core dumping code.
2014-06-29 07:02:47 +00:00
pluknet
2e4a0412a1 MFC r261901:
Preserve one character space for a trailing '\0'.
2014-06-26 08:41:54 +00:00
kib
3b20767696 MFC r267564:
In msdosfs_setattr(), add a check for result of the utimes(2) permissions test.
Refactor the permission checks for utimes(2).
2014-06-24 08:21:43 +00:00
mav
de973a144b MFC r267351:
Move root_mount_hold() functionality to separate mutex.

It has nothing to share with mutex protecting list of mounted file systems.
2014-06-22 21:21:27 +00:00
mav
48559e83fe MFC r267392:
Implement simple direct-mapped cache for popular filesystem identifiers to
avoid congestion on global mountlist_mtx mutex in vfs_busyfs(), while
traversing through the list of mount points.

This change significantly improves NFS server scalability, since it had
to do this translation for every request, and the global lock becomes quite
congested.

This code is more optimized for relatively small number of mount points.
On systems with hundreds of active mount points this simple cache may have
many collisions.  But the original traversal code in that case should also
behave much worse, so we are not loosing much.
2014-06-22 21:16:18 +00:00
mav
febec37d72 MFC r267362:
Remove unneeded mountlist_mtx acquisition from sync_fsync().

All struct mount fields accessed by sync_fsync() are protected by MNT_MTX.
2014-06-22 21:14:34 +00:00
mav
0d8805deb2 MFC r267232, r267239:
Use atomics to modify numvnodes variable.

This allows to mostly avoid lock usage in getnewvnode_[drop_]reserve(),
that reduces number of global vnode_free_list_mtx mutex acquisitions
from 4 to 2 per NFS request on ZFS, improving SMP scalability.
2014-06-22 18:06:11 +00:00
kib
1e107e92ab MFC r267255:
Change the nblock mutex to rwlock.

MFC r267264:
Devolatile as needed.
2014-06-22 08:30:43 +00:00
trasz
f5b9259f17 MFC r266007:
Initialize loginclass mutex using MTX_SYSINIT instead of using SI_SUB_CPU.
2014-06-17 13:14:31 +00:00
dchagin
4fc6560286 Revert MFC r266925 because it can lead to instant panic at fexecve():
To allow to run interpreter itself add a new ELF branding type.

Pointed out by:	kib, mjg
2014-06-17 05:21:48 +00:00
kib
71878da094 MFC r267227:
Remove write-only local variable.
2014-06-15 05:17:40 +00:00
kib
249e790152 MFC r267226:
Initialize the pbuf counter for directio using SYSINIT.
Mark ffs_rawread.c as requiring both ffs and directio options to be
compiled into the kernel.  Add ffs_rawread.c to the list of ufs.ko
module' sources.
2014-06-15 05:15:38 +00:00
jilles
e18f36ddeb MFC r267162: ktrace: Use designated initializers for the data_lengths array.
In the .o file, this only changes some line numbers (stable/10 amd64)
because element 0 is no longer explicitly initialized.

This should make bugs like FreeBSD-SA-14:12.ktrace less likely.

Discussed with:	des
2014-06-13 12:39:06 +00:00
dchagin
e871acf5e4 MFC r266925:
To allow to run the interpreter itself add a new ELF branding type.
Allow Linux ABI to run ELF interpreter.
2014-06-03 04:31:42 +00:00
kib
476a11c228 MFC r266464:
In execve(2), postpone the free of old vmspace until the threads are resumed
and exited.
2014-05-23 09:29:04 +00:00
truckman
9993a98863 MFC r266426
Slightly restructure the final loop in rman_reserve_resource_bound().
Replace with the existing loop termination test with a similar
condition from the nested "if" that may terminate the loop a bit
sooner, but still not too early.   This condition can then be removed
from the nested "if".  Relocate an operator to be style(9) compliant.
2014-05-22 00:39:49 +00:00
truckman
1c84835558 Be even more paranoid about overflow.
Requested by:	ache
2014-05-19 04:55:53 +00:00
truckman
0d5a1c60ff Nuke a couple of unnecessary assigments. Nothing uses the values of rstart
and rend after this point.
2014-05-19 04:53:43 +00:00
ian
c447f97548 MFC 264694: Fix a comment typo; conversion tables are for leap years. 2014-05-17 22:03:44 +00:00