Commit Graph

9402 Commits

Author SHA1 Message Date
christos 2a096139aa only print debugging info if we are actually going to change the permission. 2016-05-14 17:04:09 +00:00
christos f305e57def - make pax aslr stack eat up to 1/8 of the max stack space insted of 1/4
and reduce the length of the randomization bits since this is unused.
- call the pax aslr stack function sooner so we don't need to re-adjust the
  stack size.
- adjust the stack max resource limit to account for the maximum space that
  can be lost by aslr
- tidy up debugging printfs
2016-05-13 17:33:43 +00:00
ozaki-r 040205ae93 Protect ifnet list with psz and psref
The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
2016-05-12 02:24:16 +00:00
ozaki-r 472a3b6444 Fix builds of ALL kernels that define DEBUG_EXEC 2016-05-11 02:18:27 +00:00
christos 2dddb15173 Fix stack allocation; limit delta to a quarter of the stack size. This should
get rid of the random aborts.
2016-05-08 20:01:56 +00:00
christos f50af3d36b Enable DEBUG_EXEC, if we have DEBUG (since it only fires on errors) and
disable the super verbose printing by protecting it against TRACE_EXEC.
2016-05-08 20:00:21 +00:00
christos 6b2e8a5337 Move all the randomization inside kern_pax.c so we can control it directly.
Add debugging flags to be able to set the random number externally.
2016-05-08 01:28:09 +00:00
riastradh 6e111d367d Tweak comment on wapbl_flush. 2016-05-07 22:12:29 +00:00
riastradh 193947f42e Use %jx and a cast to uintmax_t, not %x, to print a dev_t. 2016-05-07 21:15:38 +00:00
riastradh 895c0fab4b Clarify comment about early exit from wapbl_flush.
Note possible bug.  Requires further analysis.
2016-05-07 21:11:51 +00:00
riastradh 2b3e02eb3e Omit unused parameter to wapbl_fini. 2016-05-07 20:59:46 +00:00
riastradh c04b67eb10 Delete debugging option wapbl_lazy_truncate. Simplify.
Likely nobody has used this in the past decade -- you would have to
enter ddb and write 1 to it in order to enable it anyway.

Patch prepared by coypu.
2016-05-07 20:39:33 +00:00
riastradh 5589cef4c7 Turn WAPBL_DEBUG panic or KASSERT into KASSERTMSG
From coypu.
2016-05-07 20:18:44 +00:00
riastradh c4a5d0a629 Document log layout and internal subroutines of vfs_wapbl.c. 2016-05-07 20:16:38 +00:00
riastradh ef3ee9e48d KASSERT(A); KASSERT(B) instead of KASSERT(A && B). 2016-05-07 17:47:34 +00:00
riastradh e551e5630a Rename labels to make wapbl_flush a little easier to follow.
out ---> wait_out
out2 ---> out

From coypu.
2016-05-07 17:12:22 +00:00
riastradh d6c3919f02 Sort and deduplicate includes. 2016-05-07 06:38:47 +00:00
pooka 7ddba29e76 regen syscall files 2016-05-06 10:19:40 +00:00
pooka a207070c4b Include non-portable <sys/idtype.h> inside RUMP_CLIENT protection. 2016-05-06 10:17:34 +00:00
riastradh 7347c31c51 Fix non-DIAGNOSTIC build. 2016-05-03 19:43:45 +00:00
riastradh 36bc16361e panic takes no \n.
From coypu.
2016-05-03 19:17:16 +00:00
riastradh 22f2d8e6d4 #ifdef DIAGNOSTIC panic ---> KASSERTMSG
From coypu.
2016-05-03 19:15:29 +00:00
christos 41f8fdba9d Simplify 2016-04-28 00:37:39 +00:00
christos cbf2c4d885 We need a flag for WCONTINUED so that we can reset it... Fixes bash issue. 2016-04-27 21:15:40 +00:00
christos d1ae6b027a set the return value to the pid if we found one (from kre@) 2016-04-25 16:35:47 +00:00
dholland 521eaa499b Define SEM_VALUE_MAX in only one place.
Adding a whole extra header file just for this is not the optimal
solution... but stuffing it in with anything else exposes things that
otherwise wouldn't be.

Nothing in userland should use <sys/semaphore.h> directly, and if some
foolish third-party software should decide to do so anyway in spite of
the instructions to the contrary I will ruthlessly break it later when
the big kernel includes cleanup finally happens.

Reported by Kamil Rytarowski, and, as it turns out, also by Klaus
Heinz in 2008.
2016-04-24 19:48:29 +00:00
christos ef9bd43259 regen 2016-04-23 23:09:27 +00:00
christos 8114776c49 Add clock_getcpuclockid2(2) as well as CLOCK_{PROCESS,THREAD}_CPUTIME_ID. 2016-04-23 23:08:26 +00:00
riastradh a65b673dfd Report what error was if nonzero with KASSERTMSG. 2016-04-22 15:01:54 +00:00
riastradh f600927ce7 #if DIAGNOSTIC panic ---> KASSERTMSG 2016-04-22 05:34:58 +00:00
knakahara 10f2dc77bc Add init function for mbuf.
some functions use mbuf as stack variable instead of allocating by m_get().
They should use this function(s) to prevent access to uninitialized fields.

Currently, the mbuf stack allocating functions are the following.
    + sys/dev/ic/bwi.c
      - bwi_rxeof()
      - bwi_encap()
    + sys/dev/ic/dp8390.c
      - dp8390_ipkdb_send()
    + sys/dev/pci/if_txp.c
      - txp_download_fw_section()
    + sys/dev/ppbus/if_plip.c
      - lptap()
    + sys/net/bpf.c
      - _pf_mtap2()
      - _pf_mtap_af()
      - _pf_mtap_sl_out()
    + sys/netisdn/i4b_ipr.c
      - ipr_rx_data_rdy()
      - ipr_tx_queue_empty()

Reviewed by kre@n.o and christos@n.o, thanks.
2016-04-20 08:50:43 +00:00
riastradh 421ddf539c Split psref_held into internal and public variants.
For internal use, we expect psrefs to be held by other LWPs when
asking in the cross-call thread whether the target in question is
referenced.

For public use, the caller should not assert about some other LWP
holding a psref.

But the rest of the logic is the same.
2016-04-13 08:31:00 +00:00
dholland 2c056b2ccb Fix (finally) the rest of PR 47040.
Revert the supporting logic in -r1.190 of vfs_lookup.c, and fix the
important change to set searchdir = NULL instead of searchdir =
foundobj. Then supply the necessary new supporting logic to cope with
some new cases where searchdir can be null.

This is at the point when lookup_once crosses a mountpoint going down;
the idea was to avoid coupling locks across filesystems as that has a
number of potentially negative consequences. At this stage of namei,
though, it's important to set searchdir to null as this is what is
used later on to handle other cases arising from crossing mount
points. If you set it to be the same as foundobj, that instead creates
the impression that you looked up "/." on the new volume, and that
causes odd things to happen in corner cases such as the one appearing
in PR 47040.

This fix ought to be pulled up to -6 and -7, and it probably could be
safely, but given the delicacy of this code and the fact that it's
taken me more than three years to find the combination of time and
intestinal fortitude to do it, as well as the minor nature of the
resulting wrong behavior observed so far, I think we'll let that part
go.

This change also exposes an annoying corner case: if you cross a mount
point and the root directory vnode of the new volume is not a
directory but a symlink, we now have no searchdir to follow the
symlink relative to. In principle one could hang onto the searchdir
from before calling lookup_once and use that, or complexify the
interface of lookup_once to hang onto it as desired for this case.
Alternatively one could add the necessary null checks to namei_follow
and allow only absolute symlinks in this case, as for an absolute
symlink one doesn't need the old searchdir. However, given that only
broken filesystems have symlinks as their root vnodes, I'm not going
to bother. Instead if this happens we'll just fail with ENOTDIR.
2016-04-12 04:02:55 +00:00
riastradh 135e13ec80 Back out previous -- <sys/intr.h> does provide splraiseipl.
Man page says <sys/param.h>, but that's wrong.

The real problem was that rump didn't have splraiseipl at all, and
that already got fixed before I woke up this morning and panicked
because I had obviously broken all the builds!
2016-04-11 13:52:23 +00:00
riastradh 4501fcf7e7 Need <sys/param.h> for splraiseipl.
How did this pass the releng autobuilds before?  We went through
several full builds of HEAD after I committed subr_psref.c.
2016-04-11 13:18:13 +00:00
christos 3f61dfb7a9 GC PAX_ASLR_EXEC 2016-04-10 15:41:05 +00:00
christos 766ba0ea82 Fix ASLR stack setup:
- make it work on machine where the stack grows up.
- use the same limits as mmap.
2016-04-10 15:26:18 +00:00
christos e9b41057d1 Add a flags sysctl for ASLR to disable particular features. We seem to be
having issues with stack setup.
2016-04-10 15:02:17 +00:00
riastradh c03dceb184 Add passive references, intermediate between pserialize and refcount.
Discussed on tech-kern:

https://mail-index.netbsd.org/tech-kern/2016/01/24/msg020069.html

API is still experimental and likely to change.  (Obvious changes:
either remove extra arguments everywhere, or shrink psref_target to a
single bit, at the expense of possibly valuable diagnostic checks.)
Should do some real testing before we use this in anger!
2016-04-09 06:21:16 +00:00
christos 57b625b6f2 remove more ifdefs 2016-04-07 12:06:50 +00:00
christos 03c12592a0 Add PAX_MPROTECT_DEBUG 2016-04-07 03:31:12 +00:00
skrll 1a04d8c9f0 Improve ddb(4) show kernhist
1) really prints all the histories merged together (rather than just the
   "first" when no argument specified
2) dumps a single history when an argument is given, e.g.
   "show kernhist usbhist"
3) uses db_printf correctly
2016-04-06 21:56:24 +00:00
roy bb67ec8f00 Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.
2016-04-06 19:45:45 +00:00
christos d583d77111 Implement WIFCONTINUED using the linux value instead of the FreeBSD one... 2016-04-06 03:51:26 +00:00
christos 9fe48813ae don't create ktrace records if we were not asked. 2016-04-06 03:11:31 +00:00
christos 5ba99e8511 Add parent notification on SIGCONT as required by waitid(2)/wait6(2) 2016-04-06 00:48:30 +00:00
christos 0fe87e3916 Simplify even more to make it clear how the status is set. 2016-04-05 14:07:31 +00:00
christos 30e54fbe0a Set the exit status code properly. 2016-04-05 13:01:46 +00:00
christos 5c35dbcd66 no need to pass the coredump flag to exit1() since it is set and known
in one place.
2016-04-04 23:07:06 +00:00
christos 4fbdf206cb Split p_xstat (composite wait(2) status code, or signal number depending
on context) into:
1. p_xexit:		exit code
2. p_xsig:		signal number
3. p_sflag & WCOREFLAG	bit to indicated that the process core-dumped.

Fix the documentation of the flag bits in <sys/proc.h>
2016-04-04 20:47:57 +00:00