Commit Graph

256 Commits

Author SHA1 Message Date
riastradh
4168fc3b21 Need only <sys/rndsource.h>, not <sys/rnd.h>.
Made this change yesterday, failed to commit it -- sorry!
2015-04-14 12:18:37 +00:00
nat
f8711ef41c Include sys/rndsource.h for rnd_add_data. 2015-04-14 06:08:03 +00:00
justin
86efea3a92 Work around pedantic compiler 2014-10-02 23:07:30 +00:00
tls
ea6af427bd Merge tls-earlyentropy branch into HEAD. 2014-08-10 16:44:32 +00:00
gson
20b11a7262 Remove the code to allow CTLTYPE_INT and CTLTYPE_QUAD to be read and
written as either 4 or 8 byte values regardless of the type, in
accordance with "Core statement on sysctl 32-bit/64-bit changes",
http://mail-index.netbsd.org/tech-kern/2014/03/26/msg016779.html.
2014-08-09 07:05:42 +00:00
joerg
e764e6c8e4 Rename old/new to match syscalls.master. 2014-06-12 22:10:04 +00:00
martin
804dc5f91b Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
2014-05-16 12:22:32 +00:00
christos
33baebc2e5 explain how a printf might happen (since it has bitten more than one person) 2014-03-27 21:09:33 +00:00
dsl
4af555d7e1 When converting out of range 64bit sysctl values to 'int' (because of
an 'int' sized read) don't assume that sizeof (int) is 4.
2014-03-01 17:27:48 +00:00
dsl
7b1adb697e Allow CTLTYPE_INT and CTLTYPE_QUAD to be read and written as either 4 or 8
byte values regardless of the type.
64bit writes to 32bit variables must be valid (signed) values.
32bit reads of large values return -1.
Amongst other things this should fix libm's code that reads machdep.sse
  as a 32bit int, but I'd changed it to 64bit (to common up some code).
2014-02-27 22:50:52 +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
maxv
52673c8d59 Reorder code to avoid using an uninitialized variable: if
sysctl_copyin fails, 'tmp' is not initialized. This bug is
harmless since only the return value will be different;
it does not expose kernel memory unless diagnostic is enabled.

ok agc@ martin@
2014-02-09 14:51:13 +00:00
pooka
73822fbe26 Put cprng sysctls into subr_cprng.c. Also, make sysctl_prng static
in subr_cprng and get rid of SYSCTL_PRIVATE namespace leak macro.

Fixes ping(8) when run against a standalone rump kernel due to appearance
of the kern.urandom sysctl node (in case someone was wondering ...)
2014-01-17 02:12:48 +00:00
christos
8c31c1cdbd fix warning 2013-04-27 20:13:16 +00:00
christos
28b4efbeda turn off debugging 2013-04-27 18:17:37 +00:00
christos
d4724c689e Add debugging info. 2013-04-27 17:13:50 +00:00
christos
4a90750c00 CID/980000: missing va_end() 2013-02-09 01:20:08 +00:00
matt
06924b3fe7 Make the inclusion of <sys/cprng.h> a private matter for sysctl. No reason
to expose the rest of the kernel to it.
2013-02-02 14:02:09 +00:00
para
8e65446416 fix the sysctl_setup_func typedef 2013-01-29 23:00:31 +00:00
christos
a5d450d94b remove useless cast (Richard Hansen) 2013-01-29 19:56:43 +00:00
matt
a9e4a2ff57 Make sure va_end is used even when errors are encountered. 2012-06-06 05:10:54 +00:00
dsl
e21a34c25e Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
  the item itself.
In the places where the caller specifies a function and a structure
  address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
  sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
  AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
  fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
2012-06-02 21:36:41 +00:00
martin
834e2aaa79 Fix query of IMMEDIATE bool values (copy & pasto). 2012-03-21 14:51:36 +00:00
tls
3afd44cf08 First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>.  This change includes
the following:

	An initial cleanup and minor reorganization of the entropy pool
	code in sys/dev/rnd.c and sys/dev/rndpool.c.  Several bugs are
	fixed.  Some effort is made to accumulate entropy more quickly at
	boot time.

	A generic interface, "rndsink", is added, for stream generators to
	request that they be re-keyed with good quality entropy from the pool
	as soon as it is available.

	The arc4random()/arc4randbytes() implementation in libkern is
	adjusted to use the rndsink interface for rekeying, which helps
	address the problem of low-quality keys at boot time.

	An implementation of the FIPS 140-2 statistical tests for random
	number generator quality is provided (libkern/rngtest.c).  This
	is based on Greg Rose's implementation from Qualcomm.

	A new random stream generator, nist_ctr_drbg, is provided.  It is
	based on an implementation of the NIST SP800-90 CTR_DRBG by
	Henric Jungheim.  This generator users AES in a modified counter
	mode to generate a backtracking-resistant random stream.

	An abstraction layer, "cprng", is provided for in-kernel consumers
	of randomness.  The arc4random/arc4randbytes API is deprecated for
	in-kernel use.  It is replaced by "cprng_strong".  The current
	cprng_fast implementation wraps the existing arc4random
	implementation.  The current cprng_strong implementation wraps the
	new CTR_DRBG implementation.  Both interfaces are rekeyed from
	the entropy pool automatically at intervals justifiable from best
	current cryptographic practice.

	In some quick tests, cprng_fast() is about the same speed as
	the old arc4randbytes(), and cprng_strong() is about 20% faster
	than rnd_extract_data().  Performance is expected to improve.

	The AES code in src/crypto/rijndael is no longer an optional
	kernel component, as it is required by cprng_strong, which is
	not an optional kernel component.

	The entropy pool output is subjected to the rngtest tests at
	startup time; if it fails, the system will reboot.  There is
	approximately a 3/10000 chance of a false positive from these
	tests.  Entropy pool _input_ from hardware random numbers is
	subjected to the rngtest tests at attach time, as well as the
	FIPS continuous-output test, to detect bad or stuck hardware
	RNGs; if any are detected, they are detached, but the system
	continues to run.

	A problem with rndctl(8) is fixed -- datastructures with
	pointers in arrays are no longer passed to userspace (this
	was not a security problem, but rather a major issue for
	compat32).  A new kernel will require a new rndctl.

	The sysctl kern.arandom() and kern.urandom() nodes are hooked
	up to the new generators, but the /dev/*random pseudodevices
	are not, yet.

	Manual pages for the new kernel interfaces are forthcoming.
2011-11-19 22:51:18 +00:00
apb
10ab3e6be4 s/null terminate/NUL terminate/ in a comment.
From PR 45422 by Greg Woods.
2011-10-05 13:24:09 +00:00
joerg
3eb244d801 Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
2011-07-17 20:54:30 +00:00
pooka
dd7a40671a Move sysctl routines from init_sysctl.c to kern_descrip.c (for
descriptors) and kern_proc.c (for processes).  This makes them
usable in a rump kernel, in case somebody was wondering.
2011-01-28 18:44:44 +00:00
mrg
18d175fa3c reject attempts to write CTLTYPE_BOOL nodes with a value other than 0 or 1. 2010-04-11 01:50:25 +00:00
pooka
065afcb61a Minimize unnecessary differences in rump. 2010-01-13 01:53:38 +00:00
elad
36ec4b320c When reporting open files using sysctl, don't use 'filehead' to fetch files,
as we don't have a process context to authorize on. Instead, traverse the
file descriptor table of each process -- as we already do in one case.

Introduce a "marker" we can use to mark files we've seen in an iteration, as
the same file can be referenced more than once.

Hopefully this availability of filtering by process also makes life easier
for those who are interested in implementing process "containers" etc.
2009-12-24 19:01:12 +00:00
pooka
11281f01a0 Replace a large number of link set based sysctl node creations with
calls from subsystem constructors.  Benefits both future kernel
modules and rump.

no change to sysctl nodes on i386/MONOLITHIC & build tested i386/ALL
2009-09-16 15:23:04 +00:00
dyoung
2d89489416 In sysctl_create(), the first character of sysctl_name is
sysctl_name[0], so write that instead of sysctl_name[sz] (where sz
just happened to be set to 0 in the previous line).

Also in sysctl_create(), give the length of the sysctl_name its
own variable, nsz, and reserve sz for expressing the size of the
node's value.

No functional change intended.
2009-08-24 20:53:00 +00:00
dyoung
210a227e29 In sysctl_realloc(), don't make 'i' act as both an child-array
iterator and the length of the old child array, but introduce a
new variable, 'olen', for the latter purpose.

In sysctl_alloc(), name a constant.

Introduce sysctl_log_print(), a handy debug routine.

No functional changes intended.
2009-08-21 22:51:00 +00:00
dyoung
5a3627a2a6 Make sure that a sysctlnode's child nodes, even nodes that are not
yet in service, have a correct pointer to their parent, sysctl_parent.
This fixes a bug where sysctl_teardown(9) could not clean up a
network interface's sysctl(9) trees when I detached it, because
the wrong log had been recorded.
2009-08-21 22:43:32 +00:00
elad
2d1c968399 Remove a few KAUTH_GENERIC_ISSUSER in favor of more descriptive
alternatives.

Discussed on tech-kern:

	http://mail-index.netbsd.org/tech-kern/2009/04/11/msg004798.html

Input from ad@, christos@, dyoung@, tsutsui@.

Okay ad@.
2009-04-15 20:44:24 +00:00
pooka
3cf15d2f4e Librate sysctl_setup_func typedef from the clutches of _MODULE and
stuff it in kern_sysctl.c where its only sensible use is.
2008-12-29 15:35:02 +00:00
pgoyette
81649575af When checking for "set-up is complete", look for the CTLFLAGS_PERMANENT
in the root of the tree being modified, rather than in the system default
tree.  This permits module compat_netbsd32 to initialize its shadow tree
at load time.

Discussed on tech-kern, with no objections.

Addresses my PR kern/40167
2008-12-19 17:28:59 +00:00
ad
0efea177e3 Remove LKMs and switch to the module framework, pass 1.
Proposed on tech-kern@.
2008-11-12 12:35:50 +00:00
christos
ff0507541f don't expose ksyms_lock 2008-10-23 20:41:13 +00:00
ad
ee66516bfd PR kern/38814 ksyms needs locking
- Make ksyms MT safe.
- Fix deadlock from an operation like "modload foo.lkm < /dev/ksyms".
- Fix uninitialized structure members.
- Reduce memory footprint for loaded modules.
- Export ksyms structures for kernel grovellers like savecore.
- Some KNF.
2008-10-20 10:24:18 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
matt
e48401e466 Add support for CTLTYPE_BOOL 2008-02-29 02:28:35 +00:00
ad
c03e2ac7c3 sysctl_free: don't have the caller acquire sysctl_treelock, do it here. 2008-01-12 19:27:27 +00:00
ad
77e0b2120f Patch up sysctl locking:
- Lock processes, credentials, filehead etc correctly.
- Acquire a read hold on sysctl_treelock if only doing a query.
- Don't wire down the output buffer. It doesn't work correctly and the code
  regularly does long term sleeps with it held - it's not worth it.
- Don't hold locks other than sysctl_lock while doing copyout().
- Drop sysctl_lock while doing copyout / allocating memory in a few places.
- Don't take kernel_lock for sysctl.
- Fix a number of bugs spotted along the way
2008-01-07 16:12:52 +00:00
ad
4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
dsl
7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
ad
63c4506184 Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
2007-08-15 12:07:23 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ad
b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
elad
1e70d64818 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 16:55:29 +00:00