Commit Graph

4977 Commits

Author SHA1 Message Date
pooka 400dd61c41 nuke unused variable to make compile 2006-10-11 09:04:16 +00:00
thorpej e160c7cdec - Add specificdata_setspecific_nowait(). Not exposed by the wrappers yet
pending discussion on tech-kern.
- Re-enable the SLEEPABLE assertion in specificdata_fini().
2006-10-11 05:37:32 +00:00
thorpej 12e8bb915e Don't free specificdata in lwp_exit2(); it's not safe to block there.
Instead, free an LWP's specificdata from lwp_exit() (if it is not the
last LWP) or exit1() (if it is the last LWP).  For consistency, free the
proc's specificdata from exit1() as well.  Add lwp_finispecific() and
proc_finispecific() functions to make this more convenient.
2006-10-11 04:51:06 +00:00
thorpej 42951eac01 Upon further reflection, make lwp_{get,set}specific() operate only on
curlwp.  Things that need to operate on "other" LWPs will get a very
special (and very private) API for their needs.
2006-10-11 03:46:42 +00:00
dogcow 55ddfc9aae change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
2006-10-10 21:49:14 +00:00
elad 5d97bceb4a Use KAUTH_PROCESS_CORENAME instead of checking securelevel. 2006-10-10 10:02:34 +00:00
martin fadbb60986 Remove unused variables. 2006-10-09 00:39:06 +00:00
christos d189b90166 Don't re-use dev in ptmopen, because we need to check the minor again for
linux. Add some more debugging.
2006-10-08 23:54:19 +00:00
christos 057b918239 add {proc,lwp}_initspecific and use them to init proc0 and lwp0. 2006-10-08 22:57:11 +00:00
christos 3ad77842ea XXX: FIXME: Cannot assert sleepable here; called from lwp_exit2 which is not. 2006-10-08 22:55:48 +00:00
thorpej 04e486d9f8 Add specificdata support to procs and lwps, each providing their own
wrappers around the speicificdata subroutines.  Also:
- Call the new lwpinit() function from main() after calling procinit().
- Move some pool initialization out of kern_proc.c and into files that
  are directly related to the pools in question (kern_lwp.c and kern_ras.c).
- Convert uipc_sem.c to proc_{get,set}specific(), and eliminate the p_ksems
  member from struct proc.
2006-10-08 04:28:44 +00:00
thorpej 31adc576d7 Add subroutines for maintaining object-specific data for arbitrary
subsystems, based on work by YAMAMOTO Takashi.  This is intended to
be used by other subsystems (such as the proc_*() or lwp_*() routines)
rather than directly by consumers.
2006-10-08 04:21:53 +00:00
oster 1d51ed695f Re-work some of the initialization code to now use config_attach_pseudo()
and friends.  Addresses PR#32881.  BOOT_FROM_RAID_HOOKS dies.
More simplification possible now.
2006-10-08 02:39:01 +00:00
gdt faa429b9b4 add missing d_type member in cdevsw initializer 2006-10-06 17:54:05 +00:00
christos 7af45af282 Fix an exploitable integer overflow found by Chris Evans of Google Security. 2006-10-06 16:17:11 +00:00
chs 33c1fd1917 add support for O_DIRECT (I/O directly to application memory,
bypassing any kernel caching for file data).
2006-10-05 14:48:32 +00:00
dogcow aaaf91526d add braces for if-else statement, in the event that SCHED_ASSERT_LOCKED is an
empty statement; shuts gcc up about 'empty statement in if-else'.
2006-10-04 23:10:42 +00:00
christos 828820606f lowercase roundup/down 2006-10-04 21:34:15 +00:00
christos 899418fb0f Coverity CID 2961: Add KDASSERT (from Arnaud Lacombe) 2006-10-03 18:16:31 +00:00
elad 5cb38e5a6c Back out previous (p_flag2).
In 30 minutes from now Jason Thorpe will come up with an implementation
of a proplib dictionary in struct proc, so adding an int doesn't really
make any sense.
2006-10-03 16:07:12 +00:00
elad f346fbdce9 Until we figure out the Perfect Way of adding flags to processes, add
a p_flag2. No objections on tech-kern@.

Input from simonb@, thanks!
2006-10-03 11:23:32 +00:00
elad b4da713cf5 Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.
2006-10-03 11:15:03 +00:00
yamt 973c582193 sa_switchcall: when giving up an upcall, backout operations correctly. 2006-10-03 09:38:29 +00:00
elad f0c7040a3f Move the kauth_init() call above auto-configuration; this will fix some
recent bugs introduced with the usage of kauth(9) in MD/device code.

While here, change the sanity checks to KASSERT(), because they're really
bugs we should fix if triggered.
2006-10-02 16:29:57 +00:00
elad 67a80f57ce Move the kauth_cred_free() call above the "is connected" check to not
leak credentials.

Pointed out by yamt@, thanks!
2006-10-02 09:22:34 +00:00
chs 164df76537 remove details of the kernel malloc() implementation from header files:
- change MALLOC() and FREE() to just call their function equivalents.
 - remove references to other malloc()-related constants.
2006-10-02 02:59:38 +00:00
elad 7aae1c8d41 Add credentials to sockets, 'so_cred'.
Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.
2006-10-02 00:02:04 +00:00
elad b8a339347f Implement the "device" scope.
It uses an authorization wrapper per device class on the system to
ensure type-safety.

For now, it supports only terminal (TTY) devices, and has two actions
for them: "open terminal" and "privileged set". Sample usage has been
added to i386 and hp300 code for reference.

Update documentation.
2006-09-30 20:05:57 +00:00
yamt 11ac1566d0 - KERNEL_LOCK_ASSERT_LOCKED: check cpu_biglock_count as well.
- implement KERNEL_LOCK_ASSERT_UNLOCKED.
2006-09-30 11:59:37 +00:00
seanb dfb8aa55d3 - Avoid array overrun in kfilter_byname_user() when all user
kfilter slots are used: no guarantee previously that last
  slot had a NULL name.
- Reuse previously deregistered user kfilter slots in
  kfilter_register().
2006-09-30 02:39:18 +00:00
christos 1d0edbd583 Coverity CID 2951, 2953, 2954: Add KASSERTS before null deref 2006-09-29 19:39:43 +00:00
elad 5c38108d28 Change the PaX mprotect(2) restrictions' "global_protection" knob to
just "global" -- it's shorter and more readable. Update documentation.
2006-09-26 14:48:40 +00:00
christos 1a9beba1e6 PR/34612: Bucky Katz: SA returns from sleep do not set the signal flags
Patch applied, many thanks for the example!
2006-09-25 18:28:56 +00:00
peter 7644942c0e Minor KNF, replace some spaces with tabs. 2006-09-24 18:24:55 +00:00
dogcow 85a1c8c4ca make powerhook_establish use const char*, not char *. This solves lots of
gcc pointer whining. Since there's one LKM that uses this function, though,
it's kernel version bump time.
2006-09-24 06:51:39 +00:00
kardel 182632b893 Reduce hardclock() code path length wrt/ multiply/divide by
re-calculating the th_scale value only when necessary.
As discussed with gdamore@. Tested at (sub-)usec level with
stratum 1 reference.
2006-09-24 06:39:28 +00:00
dogcow 78b90930eb correct dcopyout #define for !KTRACE case. 2006-09-24 05:46:14 +00:00
jmcneill f135e0d607 Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
2006-09-24 03:53:07 +00:00
manu 8a1037a46b Add a -t+S flag to ktrace for tracing activity related to sysctl. MIB
names will be displayed, with data readen and written as well.
2006-09-23 22:01:04 +00:00
xtraeme 75d2d9715c Remove duplicated includes, from Jeff Ito -> PR kern/26113. Thanks. 2006-09-23 15:36:12 +00:00
jmcneill 7ed78119d5 PR# 33260: [dM] kernel divide-by-zero for some broken disks 2006-09-23 11:51:04 +00:00
christos 1edf5bf30e PR/32682: Hauke Fath: netbsd-3 ptyfs intermittent failure with Matlab
For the benefit of linux emulation create a new minor device '2'
which is a ptmx with linux semantics. Linux changes the permissions
of the slave pty upon creation, not when grantpt(3) is called. The
glibc linux grantpt(3) checks that the pty is on ptyfs, and if it is,
it does nothing. To make use of this fix:

	mknod /emul/linux/dev/ptmx c 165 2
	chmod 666 /emul/linux/dev/ptmx

This is a lot simpler than copying a bunch of code and creating a
ptmx device just for the benefit of linux emulation.
2006-09-22 15:15:56 +00:00
thorpej 1edb40635e - Define disk information, disk geometry, and disk partition dictionary
schemas.  Disk information and disk geometry are designed to replace
  information currently conveyed to user space using struct disklabel.
- Add a dk_info member to struct disk; a reference to a disk information
  dictionary.  This dictionary is to be allocated and the reference stored
  in struct disk by individual drivers.
- disk_detach0() will release dk_info if non-NULL.
- Convert the wd(4) driver to stash geometry and other disk properties
  as the "disk-info" property in its properties dictionary.  This needs
  some cleanup, but will serve as an example of what to do with other
  disk drivers.
2006-09-22 04:48:38 +00:00
thorpej ef731d9e00 - Add a new DRVCTLCOMMAND ioctl to /dev/drvctl. This is a generic
"execute a command" ioctl that takes a dictionary as an argument
  (specifying the command and arguments) and returns a dictionary
  with the results (error code, optional error message, optional
  result data).

- Define and implement a "get-properties" command for DRVCTLCOMMAND
  that returns the properties dictionary of the specified device.

- Add a -p flag to drvctl(8) to fetch and display the properties of
  the specified device.

This is a great example of how to use prop_dictionary_sendrecv_ioctl().
2006-09-22 04:37:36 +00:00
tsutsui 292139732b Tweak some debug messages. 2006-09-20 09:37:28 +00:00
elad 6ecd7be983 Lose (void *) casts on the machdep scope authorization wrapper. Update
documentation.
2006-09-19 22:03:10 +00:00
elad 83a5239b28 Remove ugly (void *) casts from network scope authorization wrapper and
calls to it.

While here, adapt code for system scope listeners to avoid some more
casts (forgotten in previous run).

Update documentation.
2006-09-19 21:42:29 +00:00
elad cf6722febf This file is no longer needed. Securelevel is now taken care of by
secmodel_bsd44(9), see src/sys/secmodel/bsd44/secmodel_bsd44_securelevel.c

Pointed out by peter@, thanks!
2006-09-17 14:11:54 +00:00
yamt 14cd84c266 add workqueue_destroy(). 2006-09-16 11:15:00 +00:00
yamt 466a92def9 workqueue_create: use kmem_alloc rather than malloc. 2006-09-16 11:14:36 +00:00
gdamore 06522e0f81 Pass the filesystem time to clock drivers in the todr_chip_handle, so that
vax, and pmax can use it.
2006-09-16 00:50:52 +00:00
elad b60c6b99ca Introduce a new flag we mark as TRUE when we load listeners, and change
the logic in kauth_authorize_action() to use it.

When we try to authorize a request and the flag is FALSE, it means a
kernel was compiled with no listeners (or we're in very early boot stages),
and we always allow the request because it's likely to be coming from the
kernel itself or from loading an LKM with the security model (later on).

Assert that if the "listeners have been loaded" flag is FALSE, there are
really no listeners for the scope we're authorizing on.

When the flag is TRUE (ie., listeners have been loaded) but they were
later removed, creating a scope with no listeners, the request will be
denied further down.

This allows us to have the security model compiled outside the NetBSD
kernel and later loaded as an LKM, without fearing an attack will just
remove listeners we loaded earlier to create a "fail open" situation.

Input from yamt@, thorpej@, gdt@, dan@.
Okay yamt@, thorpej@.
2006-09-15 14:28:04 +00:00
yamt 97194de33c kauth_register_scope: don't leak a listener
when no default listener is specified.
2006-09-14 11:37:07 +00:00
martin c6f8d9e1e1 Avoid NULL deref (this is called with lwp=NULL from ppp interrupt context) 2006-09-13 13:28:22 +00:00
elad bada0c776a Don't use KAUTH_RESULT_* where it's not applicable.
Prompted by yamt@.
2006-09-13 10:07:42 +00:00
gdamore 747bc86364 Comment nit (remove first person), from simon@. 2006-09-12 21:38:55 +00:00
gdamore ba5268f32b Centralize rtc_offset handling for ports that __HAVE_GENERIC_TODR and use
a simple second counter instead of the clock_ymdhms support.
2006-09-12 20:47:39 +00:00
gdamore 2a1a021930 Remove attempt to incorrectly support fictional double leap seconds.
While here, make the comparisions for hour, min, and sec use ">" consistently
like the date comparisions.
2006-09-12 15:25:05 +00:00
gdamore 73700aff66 Fix to compile on platforms without __HAVE_GENERIC_TODR. Sorry about
that.  Pointed out jdc@ and he@.
2006-09-12 14:27:17 +00:00
elad de7ded0ba3 Fix typo. 2006-09-12 08:23:51 +00:00
elad 0e73c20464 Oops, add forgotten 'if'.
From Geoff Wing, thanks!
2006-09-12 07:51:29 +00:00
gdamore 58af66bd2c Add some optional debug (enabled with TODR_DEBUG) to see what your RTC
is giving you.  Also, while here, bump the threshold for "preposterous"
dates by 20 years.  Now any date earlier than late 1994 is considered
preposterous.
2006-09-12 05:47:47 +00:00
gdamore 9a6f8be8b3 Don't bother checking wday, that breaks some clock chips. Thank to Kurt Schreiner <ks at ub dot uni-mainz dot de>. 2006-09-11 20:48:55 +00:00
gdamore a012c5d7ea Allow for leap seconds. 2006-09-10 16:25:32 +00:00
gavan 843ed515f0 dsrtc_settime already takes a volatile struct timeval *, also qualify
with volatile for dsrtc_gettime.
2006-09-10 14:06:54 +00:00
blymn eee340bffe Prevent a veriexec file from being truncated. 2006-09-10 10:59:44 +00:00
tsutsui 3134621b5b Fix splclock()/splx() mismatch in previous. 2006-09-10 08:09:46 +00:00
tsutsui ca3e00268a - add more sanity checks (from playstation2/clock.c)
- fix a typo
2006-09-10 07:06:48 +00:00
yamt 4d81bcfe21 unexport getnewbuf. 2006-09-10 06:35:42 +00:00
dbj 8bcbd194da make comment match logic in cache_lookup dvp unlock code 2006-09-10 05:51:33 +00:00
manu bdfbd98ac1 When getting the program argument or environement string, we previously
assumed that all the strings were stored in a row, separated by NUL chars,
 at the address pointed bu argv[0] (or envp[0]).

This was wrong: if the program changed argvs[0], we still read the
first string correctly, but the next strings did contain unexpected data.

The fix: read the whole argv (or envp) array, then copy the string one by
one, using their addresses in argv (or agrp)
2006-09-10 05:46:02 +00:00
elad eb92c9c9aa Authorize ntp_adjtime() on the correct scope. 2006-09-09 11:52:56 +00:00
elad c2ea23c509 Add __KERNEL_RCSID(), requested by and okay xtraeme@. 2006-09-08 21:57:38 +00:00
elad 5f7169ccb1 First take at security model abstraction.
- Add a few scopes to the kernel: system, network, and machdep.

- Add a few more actions/sub-actions (requests), and start using them as
  opposed to the KAUTH_GENERIC_ISSUSER place-holders.

- Introduce a basic set of listeners that implement our "traditional"
  security model, called "bsd44". This is the default (and only) model we
  have at the moment.

- Update all relevant documentation.

- Add some code and docs to help folks who want to actually use this stuff:

  * There's a sample overlay model, sitting on-top of "bsd44", for
    fast experimenting with tweaking just a subset of an existing model.

    This is pretty cool because it's *really* straightforward to do stuff
    you had to use ugly hacks for until now...

  * And of course, documentation describing how to do the above for quick
    reference, including code samples.

All of these changes were tested for regressions using a Python-based
testsuite that will be (I hope) available soon via pkgsrc. Information
about the tests, and how to write new ones, can be found on:

	http://kauth.linbsd.org/kauthwiki

NOTE FOR DEVELOPERS: *PLEASE* don't add any code that does any of the
following:

  - Uses a KAUTH_GENERIC_ISSUSER kauth(9) request,
  - Checks 'securelevel' directly,
  - Checks a uid/gid directly.

(or if you feel you have to, contact me first)

This is still work in progress; It's far from being done, but now it'll
be a lot easier.

Relevant mailing list threads:

http://mail-index.netbsd.org/tech-security/2006/01/25/0011.html
http://mail-index.netbsd.org/tech-security/2006/03/24/0001.html
http://mail-index.netbsd.org/tech-security/2006/04/18/0000.html
http://mail-index.netbsd.org/tech-security/2006/05/15/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/01/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/25/0000.html

Many thanks to YAMAMOTO Takashi, Matt Thomas, and Christos Zoulas for help
stablizing kauth(9).

Full credit for the regression tests, making sure these changes didn't break
anything, goes to Matt Fleming and Jaime Fournier.

Happy birthday Randi! :)
2006-09-08 20:58:56 +00:00
blymn 6395103101 * Correct hashing macro so it uses FHANDLE_SIZE()
* Stop fhandle memory leaks and use the correct fhandle dealloc routine
  (thanks to Elad for these fixes)
* Remove include of kmem.h, it is not required.
2006-09-08 13:57:38 +00:00
manu 9f294e2262 When colecting a 32 bit process' argument or environement vector, we need
to convert 32 bits pointers to the 64 bit environement
2006-09-08 11:59:52 +00:00
mrg baafcdbb23 make the bpendtsleep: label only active if KERN_SYNCH_BPENDTSLEEP_LABEL
is defined.  if this option is present in the Makefile CFLAGS and we are
using GCC4, build kern_synch.c with -fno-reorder-blocks, so that this
actually works.

XXX be nice if KERN_SYNCH_BPENDTSLEEP_LABEL was a normal 'defflag' option
XXX but for now take the easy way out and make it checkable in CFLAGS.
2006-09-07 18:41:28 +00:00
gdamore 6347eaa294 Run tc_setclock at splclock(). Suggested by kardel@. 2006-09-07 15:49:49 +00:00
simonb a6e21ef05b Guard the timecounter manipulations including the call to tc_windup()
in tc_init() with splclock().  Fixes doubled-up "selected timecounter"
messages on some architectures, including pc532 and cobalt.

Fix suggested by Frank Kardel.
2006-09-07 15:48:14 +00:00
dogcow fe798dd421 Now compiles on systems without __HAVE_GENERIC_TODR 2006-09-07 07:26:07 +00:00
gdamore 8e82fb3308 Eliminate the 2038 year check, because clock_ymdhms_to_sec already performs
that check.  So instead, we test to make sure we have a non-negative second
after the conversion.

While here, we also add a check to round the second counter up when setting
time if we are more than half-way into the second.
2006-09-07 04:51:42 +00:00
gdamore 6b6be489ab Add a few consistency checks for ymdhms. Taken from the mc146818 code. 2006-09-07 04:24:26 +00:00
ad 7813695db7 Add lock_owner_onproc(). 2006-09-07 02:06:47 +00:00
uwe d9aa7ac028 Make timeval argument to todr_settime volatile to keep non-timecounter
ports happy.
2006-09-07 01:50:49 +00:00
uwe 076748ce26 Mark sizeof(tvp->tv_sec) check CONSTCOND.
No space between the sizeof and the paren.
2006-09-07 01:43:52 +00:00
ad d7c9e86f43 Track lockmgr() sleep events for lockstat. 2006-09-07 01:08:45 +00:00
gdamore 942bfe3e30 Add support for new todr entry points for drivers- todr_gettime_ymdhms and
todr_settime_ymdhms.  This allows drivers to avoid repeated conversions, and
allows us to centralize check for Y2038 overflow.   As discussed on
tech-kern.
2006-09-07 00:10:49 +00:00
blymn c09e9ac5fb * Remove "hinted" interface
* Modify fileassoc internals to use fhandle_t instead of fileid
2006-09-06 13:37:49 +00:00
matt 7cdae31eb1 Before calling todr_gettime, fill in tv.tv_sec. At least one port (vax)
needs that functionality.
2006-09-05 19:32:17 +00:00
christos 931d28e672 use c99 initializers 2006-09-03 21:39:29 +00:00
christos 842f306745 use c99 initializers 2006-09-03 21:12:14 +00:00
gdamore 7b0092122f Update the base time (used when no filesystem or rtc time exists) to 12pm,
Jan 1, 2006. This is somewhat arbitrary, but its a heck of a lot better than
mid 1991. :-)
2006-09-03 17:13:04 +00:00
martin e0c4f3147e Fix %X in kernel printf, from Arnaud Degroote in PR kern/34459. 2006-09-03 17:06:36 +00:00
christos 28ea22fb52 use c99 initializers, per gimpy's request 2006-09-03 06:40:39 +00:00
gdamore 487ed45995 Don't warn about RTC losing/gaining days if the filesystem time is bogus. 2006-09-03 06:37:55 +00:00
christos be15e5387b use c99 initializers 2006-09-03 06:34:34 +00:00
christos e2ea4b04bb avoid empty else statement 2006-09-03 06:25:19 +00:00
christos a307d25b10 add missing initializer 2006-09-03 06:24:21 +00:00
gdamore a6abab1852 Incorporate changes from x86/i386 as follows:
1) don't set a clock when panicing during early boot
2) if the filesystem time is newer than the rtc time (by at least 2 days) then
revert to the filesystem time.
3) use x86 style messaging.

We still use a threshold of 2 days of gain or loss in time to warn though.
2006-09-03 05:25:05 +00:00
gdamore c583da0d13 Add MI implementation of inittodr, todr_attach, and resettodr.
This is triggered upon __HAVE_GENRIC_TODR in machine/types.h.  Conversion of
evbmips port forthcoming.
2006-09-02 20:18:00 +00:00