Commit Graph

4513 Commits

Author SHA1 Message Date
yamt
707ea62186 sysctl_kern_bufq_strategies: skip a dummy strategy correctly. 2005-10-16 08:27:51 +00:00
christos
c4dfab8cf0 Make the grouplist invalidate function take a grouplist instead of a group.
Suggested by yamt.
2005-10-16 02:55:18 +00:00
christos
762d3ada2a This is why I hate gotos: My previous change had different semantics than
the original code since if fullgroups was empty and partgroups wasn't, we
would not clean up partgroups (pointed out by yamt). Well, this one has
different semantics from the original, they are the correct ones I think..
2005-10-16 02:21:40 +00:00
yamt
9f4759ccce add some bufq helper functions.
#if 0'ed out as there is no user currently.
2005-10-16 02:02:23 +00:00
yamt
4c9b2e4a8f whitespace. 2005-10-16 00:30:03 +00:00
yamt
834e69f6e0 fix rcsid. 2005-10-16 00:28:32 +00:00
christos
1e976481fe avoid a goto. 2005-10-16 00:28:04 +00:00
xtraeme
40b7fffb63 Add a sysctl function that will print all buffer queue strategies
built in the kernel:

$ sysctl kern.bufq.strategies
kern.bufq.strategies = disksort fcfs priocscan readprio
$
2005-10-15 22:36:18 +00:00
chs
528fa60e43 in pool_do_cache_invalidate(), make sure to process both full and partial
group lists even if the first one we look at is empty.  fix ddb print routine.
2005-10-15 21:22:46 +00:00
elad
e47c05bf2b copystr and copyinstr return int, not void. 2005-10-15 21:18:54 +00:00
xtraeme
2228b00dd4 This needs <sys/bufq_impl.h> 2005-10-15 19:57:24 +00:00
yamt
aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
christos
f31d6316f6 No need for __UNCONST in previous commit; factor out the function call. 2005-10-14 17:18:59 +00:00
elad
8fa0fa95d8 Copy the path to a kernel buffer before using it from ndp, as it may be a
pointer to userspace.
2005-10-14 12:47:04 +00:00
christos
0d55f64fcb - lock the tty when playing with the kqueue list.
- don't return 1, when we expect to return errno [EPERM is kind of stupid
  in this case :-)]
2005-10-13 16:18:43 +00:00
elad
d4a8a9ec63 Debug nits from Brett Lymn:
- The fingerprint should be printed before we increment the pointer.
  - Add missing index increment.
2005-10-12 14:26:47 +00:00
elad
5068eab154 - Don't pass NULL to free().
Fixes local crash reported by Matthew Sporleder.

- %ld -> PRIu64 for inodes.
2005-10-11 23:59:40 +00:00
elad
95d7879011 Style changes, lots of input from blymn@. 2005-10-10 17:36:29 +00:00
yamt
2db36492c6 sa_switch: remove cpu hand-off in "Case 2".
it causes severe unfairness in some cases.
eg. when a process has many lwps doing poll.

no objections on tech-kern@.
2005-10-08 06:37:12 +00:00
yamt
c610dbbdc2 sysctl_kern_proc_args: don't assume that the process is
resident while we are sleeping.
2005-10-08 06:35:56 +00:00
isaki
a658e0cd29 regen. 2005-10-08 06:15:30 +00:00
chs
20b89dd47f default to simple_lock_debugger=1 with LOCKDEBUG. 2005-10-08 03:18:25 +00:00
elad
2de72bfe34 Various fixes from blymn@ and myself.
Also, put genfs changes under #if 0, and don't do per-page fingerprints
until this is properly discussed, as requested by yamt@.
2005-10-07 18:07:46 +00:00
simonb
4beb6d8640 Add a hack to deal with MIPS relocatable shared-linker problem on
COMPAT_16 and earlier that results in a current shared linker running at
address 0 (and thus allows NULL pointer derefs to work).

As noted by Matthias Drochner, this "fix" just checks the first psection
and not the first loadable psection.  This isn't a problem with the
binutils up to now, but might be in the future.
2005-10-07 08:33:10 +00:00
yamt
2975f576b9 uninline scheduler hooks. 2005-10-06 07:02:13 +00:00
elad
314759431d Don't forget to unmap memory once we're done with it.
Pointed out by yamt@.
2005-10-05 16:21:46 +00:00
elad
4daa338c1a Don't use static variables here.
Pointed out by yamt@.
2005-10-05 15:59:31 +00:00
yamt
d6d16da423 remove a redundant assignment in the previous. 2005-10-05 15:46:00 +00:00
elad
8fc0d7a9c3 Introduce per-page fingerprints in Veriexec.
This closes a hole pointed out by Thor Lancelot Simon on tech-kern ~3
years ago.

The problem was with running binaries from remote storage, where our
kernel (and Veriexec) has no control over any changes to files.

An attacker could, after the fingerprint has been verified and
program loaded to memory, inject malicious code into the backing
store on the remote storage, followed by a forced flush, causing
a page-in of the malicious data from backing store, bypassing
integrity checks.

Initial implementation by Brett Lymn.
2005-10-05 13:48:48 +00:00
mrg
8b78edeb42 fix a bug pointed out by der mouse on tech-kern: in F_GETOWN, use a
pointer to a temporary "int" variable to pass to fo_ioctl(TIOCGPGRP), not
a register_t pointer.  (how did F_GETOWN ever work on sparc64 before?)
2005-10-03 02:06:00 +00:00
chs
7c02feca68 avoid calling into the pool code while holding sched_lock
since both pool_get() and pool_put() can call wakeup().
instead, allocate the struct sadata_upcall before taking
sched_lock in mi_switch() and free it after releasing sched_lock.

clean up some modularity warts by adding a callback to
struct sadata_upcall for freeing sa_arg.
2005-10-02 17:51:27 +00:00
chs
9c47d944e4 optimize pool_caches similarly to how I optimized pools before:
split the single list of pool cache groups into three lists:
completely full, partially full, and completely empty.
use LIST instead of TAILQ where appropriate.
2005-10-02 17:29:31 +00:00
jdolecek
05a8b02adf log when traced process is orphaned
PR: 17388 by Greg A. Woods
2005-10-01 21:07:38 +00:00
yamt
163be2ac64 change_utimes: use nanotime(9) rather than time(9). 2005-10-01 06:13:42 +00:00
yamt
f615d37667 simplify lwp exit code. 2005-10-01 06:12:44 +00:00
christos
2cbe95f3ac Regen. 2005-09-26 03:04:46 +00:00
christos
65a3ca6215 some of the extattr syscalls return ssize_t not int. 2005-09-26 03:02:19 +00:00
jmmv
3955cf65f9 Add some COMPAT_30 code to let old mountd binaries work after the NFS
exports rototill.
2005-09-25 21:57:40 +00:00
isaki
ff87e380de Correct typo in a comment. ok'ed by wiz@. 2005-09-25 12:50:14 +00:00
jmmv
2a3e5eeb7c Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
  function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
  file sys/nfs/nfs_export.c.  The former was becoming large and its code
  is always compiled, regardless of the build options.  Using the latter,
  the code is only compiled in when NFSSERVER is enabled.  While doing this,
  also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
  path and a set of export entries.  At the moment it can only clear the
  exports list or append entries, one by one, but it is done in a way that
  allows setting the whole set of entries atomically in the future (see the
  comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
  that it becomes file system agnostic.  In fact, all this whole thing was
  done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
  exports initialization; done internally by the kernel when initializing
  the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
  subsystems can run arbitrary code upon receipt of specific VFS events.
  At the moment, this only provides support for unmount and is used to
  destroy NFS exports lists from the file systems being unmounted, though it
  has room for extension.

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 12:10:31 +00:00
yamt
a0093a4cf5 uninline vn_start_write and vn_finished_write as they are big enough. 2005-09-20 09:49:01 +00:00
christos
238c109f03 move compat code to the compat tree. 2005-09-13 01:45:14 +00:00
christos
291ee3d215 Introduced nanotime() which is going to be used by some fs code yet to
be committed. This should really be an MD routine and microtime should
be implemented from it, not the opposite (which is what we have now).
2005-09-12 16:21:31 +00:00
christos
74051a244a PR/27185: Christian Biere: kqueue: EOF on pipe gains no EVFILT_READ event
Set the PIPE_EOF flag before we wakeup() our peer. While here GC unused
argument from pipeselwakeup() and call it even when fp == NULL.
2005-09-11 17:55:26 +00:00
drochner
241cff4694 make use of the locator information: print "?" if a locator is
at its default value, and accept "?" in the "change" command
2005-09-08 14:58:14 +00:00
christos
a531e09eeb Revert incomplete (and possibly incorrect) sys_sa_preempt implementation
that I committed accidentally with the 64 bit inode changes.
2005-09-07 23:31:06 +00:00
elad
d1e2d78dee Use `l'' and not `curlwp''. Thanks to Peter Postma for catching this. 2005-09-07 18:06:04 +00:00
elad
fb3e9eee95 Implement curtain for AF_LOCAL PCB lists. 2005-09-07 17:38:44 +00:00
elad
bc433a82fb Implement curtain in KERN_{PROC,PROC2,FILE,FILE2,PROC_ARGS}.
While I'm here, disable curtain by default.
2005-09-07 17:30:07 +00:00
elad
ec14f2d11e Introduce ``security.curtain'', new node for security features and
settings, and new variable for controlling access to objects based
on user-id.
2005-09-07 16:26:15 +00:00
rpaulo
f305bcafe3 Implement kern.hardclock_ticks. 2005-09-06 02:36:17 +00:00
yamt
af9e3184f8 prevent sa_setconcurrency before sa_enable, rather than crashing.
(savp_lwp is still null at that point.)

noted by skrueger at meinberlikomm.de.
2005-09-05 21:52:38 +00:00
martin
6dd6a3eb59 In adjust_rights() Use CMSG_SPACE() to calculate the number of
filedescriptors passed in this message - the counterpart in
unp_externalize does this as well.

Note that CMSG_SPACE(0) does not make sense, since it does not invoke
the alignment magic - so use CMSG_SPACE(sizeof(int)) and adjust the
calculated total later.

This fixes the postfix conection cache for 64bit platforms. Previously
the number of passed filed descriptors (nfds) would have been
calculeted too high, causing the fdrelease() of uninitialized junk.
2005-09-03 22:48:35 +00:00
martin
f435538d40 minor knf tweak 2005-09-03 19:44:20 +00:00
rillig
aede7f6775 Made the code of the grsortu function smaller and simpler. Ok'ed by
christos.
2005-09-02 20:51:53 +00:00
elad
b0e6e3b381 Sync comments with 64-bit inode changes. 2005-09-02 14:16:50 +00:00
jmmv
b077bb7f72 Honor the user's umask while creating local sockets. Several other systems
do already this (such as FreeBSD, OpenBSD and Linux), so it will improve
portability of some third-party programs.  No objections in tech-kern@.
2005-08-30 15:03:04 +00:00
jmmv
0562a5484c Make all creation operations (mkdir, create, mknod and symlink) consistent
by changing the symlink one to set vap's vatype to VLNK.  All the other three
already set vatype to the correct type.  Note that, however, in the mkdir
case (and now symlink too) this is not strictly necessary.
2005-08-30 09:37:41 +00:00
drochner
a45a6c9839 in mapply(), call config_match() instead duplicating its code 2005-08-29 19:13:48 +00:00
reinoud
f4a3f04cb2 Create functions ioctl_copyin() and ioctl_copyout(). They are meant to be
used in ioctl routines to do the right thing when the FKIOCTL flag is
passed to the IOCTL routine indicating its a in-kernel VOP_IOCTL call and
indirect addresses provided in the arguments are to be seen as kernel
adresses rather than userland adresses.

A simple substitution and prepending of the `flags' passed on to the ioctl
handler is enough to DTRT.
2005-08-28 20:58:14 +00:00
yamt
9020ca379a protect p_nrlwps by sched_lock. no objection on tech-kern@. PR/29652. 2005-08-28 14:57:18 +00:00
drochner
f557755d9f nuke locdesc_t from orbit 2005-08-26 14:20:40 +00:00
drochner
90c378642f now that we have information about default locator values
we can implement an universal submatch() function covering all
the standard cases:
if (<configured> != <wildcard> && <configured> != <real>)
	then fail
else
	ask device match function
2005-08-25 22:17:19 +00:00
drochner
fa3cb84d62 replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
2005-08-25 18:35:38 +00:00
drochner
6036af9fc4 Replace the "locnames", attached to cfdata, which was solely good for
userconf, by more complete information (including default values) about
interface attributes, attached to the drivers which provide them.
2005-08-25 15:06:28 +00:00
simonb
fbcb9c4760 Fix a tyop in a comment. 2005-08-24 16:00:54 +00:00
christos
62ea392e41 in setgroups(), sort -u the gid_t array to make sure that comparisons are
consistent.
2005-08-23 07:58:58 +00:00
rillig
20f0c3a484 Bugfix: In crcmp, compare n group IDs instead of only n bytes.
Added a big FIXME because two group lists containing the same entries,
but ordered differently, still compare as unequal. The same holds if one
group list contains an entry twice while the other does not. ok'ed by
christos.
2005-08-22 15:10:50 +00:00
yamt
ebfab35576 old_sysctl: fix null dereference when oldlenp == NULL. 2005-08-21 13:14:54 +00:00
yamt
6f645a09cb introduce a variant of disk_attach/detach, for pseudo disks
which is opened by user before being attached.
2005-08-20 12:00:01 +00:00
christos
b33f6da979 more 64 bit inode lossage. 2005-08-19 16:58:29 +00:00
elad
5f794fb20d Introduce veriexec_renamechk().
Rename policy:
  - Strict levels 0, 1: Log renames of monitored files.
  - Strict level 2: Prevent renames of monitored files.
  - Strict level 3: Prevent renames.
2005-08-19 12:30:02 +00:00
christos
50f8955b6e 64 bit inode changes. 2005-08-19 02:04:03 +00:00
christos
d2d5cc4265 Better debugging info on failure 2005-08-19 02:04:02 +00:00
christos
758a209d23 64 bit inode changes. 2005-08-19 02:03:49 +00:00
yamt
2e85eff671 - introduce M_MOVE_PKTHDR and use it where appropriate.
intended to be mostly API compatible with openbsd/freebsd.
- remove a glue #define in netipsec/ipsec_osdep.h.
2005-08-18 00:30:58 +00:00
elad
c62f8b0f18 The veriexec API uses dev_t and ino_t for device and inode numbers.
VOP_GETATTR() fills a struct vattr, where va_fsid and va_fileid (device
and inode..) are typed as long.

Add some casts when using these values and surround them with XXXs about
the potential size mismatch, as long can be 64 bits but dev_t and ino_t
are always 32 bits. This is safe because *for now* we're still using
32 bit inode numbers.

Discussed with blymn@.
2005-08-13 12:56:44 +00:00
elad
79b2f66712 Fix printing formats.
- size_t is %zu
  - dev_t is uint32_t is %u
  - long is %ld
2005-08-13 12:08:34 +00:00
blymn
01d37a82c0 Remove the tape stats from here, they caused issues on non-scsipi
architectures.
2005-08-13 10:48:27 +00:00
yamt
5a3ce82137 exit_lwps: fix a race with eg. sa_setwoken.
ie. "exit_lwps: lwp_wait1 failed with error 11"
PR/30689.
2005-08-10 09:44:02 +00:00
yamt
98d4a17db9 exit_lwps: fix a race which causes a panic "setrunnable: lwp %p state was %d". 2005-08-10 09:42:03 +00:00
blymn
c0065dc0df Don't include tape stats functions if no devices configured. 2005-08-08 12:12:30 +00:00
blymn
ad6c334dcd Add tape statistics gathering functions. 2005-08-07 12:28:34 +00:00
yamt
f37bf52fce sysctl_create: remove an unused variable. 2005-08-07 04:54:07 +00:00
jmmv
5aff10d277 Fix some typos in comments. 2005-08-05 13:22:23 +00:00
jmmv
060dc147c7 Fix wording in a comment. 2005-08-05 13:18:32 +00:00
junyoung
fb1a9a3413 Use NULL where appropriate. 2005-08-05 11:14:32 +00:00
junyoung
28f7bf4885 Cosmetic changes. 2005-08-05 11:05:44 +00:00
junyoung
683f615a8f Move proc0 initialization from main() in init_main.c and proc0_insert() in
kern_proc.c into a new function proc0_init() in kern_proc.c, as suggested
on tech-kern@ days ago.
2005-08-05 11:03:18 +00:00
elad
6e4a854552 Support multiple entry types. Direct, indirect, and file can now be
combined in the signatures file using commas.
2005-08-02 16:14:10 +00:00
elad
f73e4c7b31 Simplify previous commit. 2005-07-29 22:57:34 +00:00
elad
3c0a7f641b Use real executed program in logs instead of the script that was executed.
For example, this used to give false logs of matching fingerprint for
foo.sh while foo.sh don't have an entry, and the program executed (and
matching the fingerprint) is the interpreter - /bin/sh.
2005-07-29 22:37:11 +00:00
elad
753edff337 #ifdef VERIFIED_EXEC 2005-07-29 14:49:00 +00:00
christos
5d719b264e In the SIGIO case, only check that we are the controlling tty if we are a
session leader.
2005-07-25 17:32:03 +00:00
peter
cea97248d3 Fix an off-by-one in checking the return value of strlcpy(9).
Reviewed by atatat.
2005-07-23 23:34:52 +00:00
cube
875e65cda6 Introduce __sigtimedwait1 which will help adding COMPAT_NETBSD32 support
for __sigtimedwait(2).
2005-07-23 22:02:13 +00:00
cube
2844b7b432 Split sys_timer_create, sys_timer_gettime and sys_timer_settime so they
can be easily used by netbsd32 code.

XXX Meanwhile, introduce a copyinout_t type that matches the prototype of
XXX copyin(9) and copyout(9).  Its logical place would be in systm.h, near
XXX the definition of copyin, but, well, see the comment.
2005-07-23 18:54:07 +00:00
erh
5a521f35e0 Fix a null vp panic when creating a file at veriexec strict level 3. 2005-07-23 18:19:51 +00:00
yamt
b7bfe82866 update file timestamps for nfsd loaned-read and mmap.
PR/25279.  discussed on tech-kern@.
2005-07-23 12:18:41 +00:00
junyoung
06e730ed76 More cosmetic changes. 2005-07-17 23:53:57 +00:00
junyoung
a226b79f42 Make code prettier. 2005-07-17 23:49:49 +00:00
christos
9213de1869 catch up with verified exec defopt changes. 2005-07-17 05:22:34 +00:00
christos
1510fe1543 defopt verified_exec. 2005-07-16 22:47:18 +00:00
simonb
bf458186f4 White space KNF nit. 2005-07-15 03:59:31 +00:00
christos
190b607a00 Add missing const. Reported by Allar Ritter in tech-kern. 2005-07-13 04:24:26 +00:00
cube
355bcba766 Split sys_execve() and add execve1() that does most of the work, and takes
as an argument a function that will retrieve an element of the pointer
arrays in user space.  This allows COMPAT_NETBSD32 to share the code for
the emulated version of execve(2), and fixes various issues that came from
the slow drift between the two implementations.

Note:  when splitting up a syscall function, I'll use two different ways
       of naming the resulting helper function.  If it stills does
       copyin/out operations, it will be named <syscall>1().  If it does
       not (as it was the case for get/setitimer), it will be named
       do<syscall>.
2005-07-11 20:15:26 +00:00
cube
08fd92bac5 Split sys_getitimer and sys_setitimer to make it possible to share the
relevant code with the COMPAT_NETBSD32 version, and make the latter use
the new functions.

This fixes netbsd32_setitimer() which had drifted from the native syscall
and did not work properly anymore.
2005-07-11 19:50:42 +00:00
thorpej
f5546fc71e Move the rest of the extattr stuff into vfs_xattr.c 2005-07-10 22:10:00 +00:00
thorpej
9c6adeffa0 Regen:
Add Linux-compatible {,fl}{get,set,list}xattr() system call interface
to the VFS extended attribute subsystem.
2005-07-10 22:05:24 +00:00
thorpej
ccbebfaaf1 Add Linux-compatible {,fl}{get,set,list}xattr() system call interface
to the VFS extended attribute subsystem.
2005-07-10 22:04:20 +00:00
cube
cbb77bc452 The comment listing the arguments of fsync_range(2) wrongly described
"length" as an int.  It is an off_t.
2005-07-10 14:26:02 +00:00
christos
ec1dc88c1d define syscall here. 2005-07-10 04:20:34 +00:00
christos
df1b79805d don't declare syscall and syscall_intern. 2005-07-10 00:54:54 +00:00
thorpej
76fd10b45a Move VFS extended attribute support to its own file. 2005-07-09 01:05:23 +00:00
christos
ac0ee9b2c0 Allow F{G,S}OWN to succeed on a tty that has no session associated with it,
and it is not the controlling tty. This change allows us to use SIGIO on
a non-controlling tty (eg. debug ntpd with a refclock on a tty).
2005-07-07 00:01:32 +00:00
thorpej
f44b62c49d Collect vmcmd statistics. 2005-07-06 23:08:57 +00:00
christos
de124326cb Make copy{in,out}_proc work on all processes (including curproc) by
special-casing the curproc case. Use copy{in,out}_proc directly instead
of checking for curproc each time. Discussed with thorpej.
2005-07-06 22:30:42 +00:00
kleink
c6cc410a70 Addendum to previous: copyin_proc() must not be used on curproc. 2005-07-06 20:56:49 +00:00
kleink
e3c2a9c2f6 Use copyin_proc() to peek for trailing zeroes in sections, as we might be
running in a different context (i.e. a process tracing).
2005-07-06 20:31:33 +00:00
thorpej
d697722880 A few tweaks to magic symlinks:
- Add a @{var} syntax in addition to @var.  This allows for patterns like
  @{ostype}-@{osrelease}-@{machine_arch}.
- Add a @emul variable that expands to the process's emulation name
  (e.g. "netbsd", "netbsd32", "linux", etc.)
2005-07-06 18:53:00 +00:00
elad
ab856de1bc Use `const struct sysctlnode *veriexec_count_node' so it works with the
recent changes in sysctl(9).
2005-07-01 19:50:04 +00:00
drochner
0ca89e9c3a clean up duplication which was to support the old (not locator passing)
API for bus "submatch" functions
2005-06-28 18:37:34 +00:00
elad
1b7133edad From marius@openbsd:
Fix an issue when scripts are executed under systrace where the argv[0]
would be normalized, and hence break scripts that depend on how they were
called.
2005-06-27 17:11:20 +00:00
elad
8ebc2e9bee From marius@openbsd:
Add an exec message so that whenever a set-uid/gid process executes a new
image which we may control, the exec does not go by unnoticed.
2005-06-26 19:58:29 +00:00
riz
67399f088e Use %zx in a format string to print a size_t, not %lx, so a kernel
with KSYMS_DEBUG will compile.
2005-06-25 05:30:04 +00:00
christos
0064ddfe2b the magic number is not byte-swapped. 2005-06-25 02:22:57 +00:00
thorpej
73c9fbb0e6 Use ANSI function decls. Apply some static. 2005-06-23 23:15:12 +00:00
thorpej
2f6855b6ca Use ANSI function decls. 2005-06-23 18:46:17 +00:00
thorpej
6e4d6e6cdb Use ANSI decls, liberally apply static. 2005-06-23 18:44:44 +00:00
thorpej
e871a0392f Remove the last references to M_NAMEI; everything should be using PNBUF_*()
now (for a long time now).  Remove M_NAMEI, and bump the kernel version to
3.99.7 to reflect its removal.
2005-06-23 17:00:30 +00:00
thorpej
65412a2710 Implement expansion of special "magic" strings in symlinks into
system-specific values.  Submitted by Chris Demetriou in Nov 1995 (!)
in PR kern/1781, modified only slighly by me.

This is enabled on a per-mount basis with the MNT_MAGICLINKS mount
flag.  It can be enabled at mountroot() time by building the kernel
with the ROOTFS_MAGICLINKS option.

The following magic strings are supported by the implementation:

	@machine	value of MACHINE for the system
	@machine_arch	value of MACHINE_ARCH for the system
	@hostname	the system host name, as set with sethostname()
	@domainname	the system domain name, as set with setdomainname()
	@kernel_ident	the kernel config file name
	@osrelease	the releaes number of the OS
	@ostype		the name of the OS (always "NetBSD" for NetBSD)

Example usage:

	mkdir /arch/i386/bin
	mkdir /arch/sparc/bin
	ln -s /arch/@machine_arch/bin /bin
2005-06-23 00:30:28 +00:00
elad
6e7c7658ef Fix logic in verbose printing. 2005-06-22 21:50:27 +00:00
ws
9d78e0cf36 PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
2005-06-21 14:01:11 +00:00
elad
0e4dfe1792 - Use more calls to veriexec_report() where possible.
- Change #ifdef VERIFIED_EXEC_VERBOSE to another verbose level, 2. Add
  sysctl(3) bits.

- Simplify access type conflict handling during load. This depends on
  the values of access type defines to be ordered from least to most
  'strict'.
2005-06-20 15:06:18 +00:00
atatat
df13e3579e Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone.  Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
2005-06-20 02:49:18 +00:00
elad
c3caa55d4d - Avoid pollution of struct vnode. Save the fingerprint evaluation status
in the veriexec table entry; the lookups are very cheap now. Suggested
  by Chuq.

- Handle non-regular (!VREG) files correctly).

- Remove (no longer needed) FINGERPRINT_NOENTRY.
2005-06-19 18:22:36 +00:00
thorpej
9616fa6458 Fix some locking issues:
- Make the locking rules for pr_rmpage() sane, and don't modify fields
  protected by the pool lock without actually holding it.
- Always defer freeing the pool page to the back-end allocator, to avoid
  invoking the pool_allocator with the pool locked (which would violate
  the pool_allocator -> pool locking order).
- Fix pool_reclaim() to not violate the pool_cache -> pool locking order
  by using a trylock.

Reviewed by Chuq Silvers.
2005-06-18 01:34:03 +00:00
atatat
efb4270746 Comment in new cp_id implementation was wrong since I abandoned
rewriting it in favor of some testing and then never got back to it.
It's better now.
2005-06-17 23:53:21 +00:00
elad
97d75abb70 Oops. Don't allow file delete even if it's not monitored if we're in
lockdown mode (strict level 3).
2005-06-17 22:39:08 +00:00
elad
ad7b01f7d0 More veriexec changes:
- Better organize strict level. Now we have 4 levels:
  - Level 0, learning mode: Warnings only about anything that might've
      resulted in 'access denied' or similar in a higher strict level.

  - Level 1, IDS mode:
    - Deny access on fingerprint mismatch.
    - Deny modification of veriexec tables.

  - Level 2, IPS mode:
    - All implications of strict level 1.
    - Deny write access to monitored files.
    - Prevent removal of monitored files.
    - Enforce access type - 'direct', 'indirect', or 'file'.

  - Level 3, lockdown mode:
    - All implications of strict level 2.
    - Prevent creation of new files.
    - Deny access to non-monitored files.

- Update sysctl(3) man-page with above. (date bumped too :)

- Remove FINGERPRINT_INDIRECT from possible fp_status values; it's no
  longer needed.

- Simplify veriexec_removechk() in light of new strict level policies.

- Eliminate use of 'securelevel'; veriexec now behaves according to
  its strict level only.
2005-06-17 17:46:18 +00:00
christos
dfa8191fb3 Add a new sysctl 'cp_id' that returns the array of cpu id values. Requested by
me, implemented by atatat.
2005-06-16 14:55:58 +00:00
yamt
91fa31b5d2 uipc_usrreq: plug mbuf leak. 2005-06-16 14:36:42 +00:00
elad
e62596b887 Set the veriexec table entry pointer to NULL in getnewvnode(). 2005-06-15 16:59:27 +00:00
elad
5b2713d417 Fix sysctl handling for raise-only variables. This affected the veriexec
node entirely. Reported by Nino Dehne.
2005-06-15 16:58:31 +00:00
elad
8863b29522 Sync reality with comments. This makes strict level 1 work as expected.
Reported by Nino Dehne.
2005-06-14 21:55:21 +00:00
elad
ab99f231f8 Correctly handle the case of executing a 'FILE' entry. 2005-06-13 22:46:56 +00:00
elad
1e323dd70c Fix potential NULL pointer access. 2005-06-13 21:09:49 +00:00
elad
49d0a3504e Cosmetic change.. 2005-06-13 20:52:13 +00:00
elad
cbb4bd85d4 Oops - forgot to remove it in previous commit. Checking the fingerprint
status is enough here.
2005-06-13 20:23:15 +00:00
elad
da15a5a10c More veriexec refactoring.
- Use u_char for the fingerprint status.
  - Add a pointer to the vnode's veriexec hash table entry in the vnode
    struct. This saves a lookup and will also used by planned features.
  - When removing a file from the tables, set the vnode fingerprint status
    to NOENTRY.
  - Add switch to do flag-specific handling in veriexec_verify(). At the
    moment this prevents execution of FILE entries in strict level 2, but
    it will also be used by planned features.
  - Use memset() instead of bzero().
  - Various cosmetic changes.
2005-06-13 20:17:54 +00:00
christos
51b633d452 Remove an extraneous TTY_UNLOCK. With a LOCKDEBUG kernel, sending FLUSHO
causes a locking assertion.
2005-06-11 22:42:24 +00:00
elad
6533bc4abd Work according to veriexec strict level, not securelevel. Also, use the
veriexec_report() routine when possible; and when opening a file for writing,
only invalidate the fingerprint - not always the data will be changed.
2005-06-11 16:04:59 +00:00
elad
9cafbe15bc Use the defined VERIEXEC_DIRECT instead of the (incorrect) 0 magic number. 2005-06-10 23:32:16 +00:00
matt
e1245a3c46 Rework the coredump code to have no explicit knownledge of how coredump
i/o is done.  Instead, pass an opaque cookie which is then passed to a
new routine, coredump_write, which does the actual i/o.  This allows the
method of doing i/o to change without affecting any future MD code.
Also, make netbsd32_core.c [re]use core_netbsd.c (in a similar manner that
core_elf64.c uses core_elf32.c) and eliminate that code duplication.
cpu_coredump{,32} is now called twice, first with a NULL iocookie to fill
the core structure and a second to actually write md parts of the coredump.
All i/o is nolonger random access and is suitable for shipping over a stream.
2005-06-10 05:10:12 +00:00
atatat
420d91208b Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code.  I know it's not the prettiest code, but it seems to work rather
well in spite of itself.
2005-06-09 02:19:59 +00:00
scw
50d7457a5f Thou shalt not allocate PAGE_SIZE automatic variables on the kernel stack. 2005-06-08 07:25:12 +00:00
jdc
e0dc2d1568 Revert previous ('_ncpus' is now 'ncpus' again).
MI variable names have precedence.
2005-06-06 19:56:46 +00:00
yamt
11bfc2d8e1 introduce a macro to initialize uvm_object and use it. 2005-06-06 12:09:19 +00:00
martin
71d020f371 Since we decided "const struct mbuf *" would not do the right thing (tm),
remove ~all const from mbuf pointers.
2005-06-06 06:06:50 +00:00
martin
36c7f61f8f Constify the source arg of m_copydata 2005-06-06 04:50:28 +00:00
thorpej
b1a8db7e02 Use ANSI function decls. 2005-06-05 23:47:48 +00:00
thorpej
30fe14b30e Re-arrange slighty, eliminate prototypes that are unnecessary when using
ANSI function decls with "static".
2005-06-05 23:10:25 +00:00
jdc
a406dfbd14 Rename 'ncpus' to '_ncpus', otherwise we shadow sparc/sparc64's 'ncpus'
when MULTIPROCESSOR is defined.
2005-06-05 21:22:20 +00:00
thorpej
daf3614dbb Remove this version of genassym; nothing uses it. 2005-06-05 18:26:19 +00:00
jdc
f13fcfe512 Rename 'ncpus' to '_ncpus', otherwise we shadow sparc/sparc64's 'ncpus'
when MULTIPROCESSOR is defined.
2005-06-05 09:04:49 +00:00
uwe
fb2315c16b Constify argument to ttyldisc_lookup and ttyldisc_remove. 2005-06-04 22:45:11 +00:00
he
1d07c48176 An Elf32_Addr can't be cast to caddr_t without first being cast to intptr_t
without causing a warning (turned into error).  Fixes build problem for amd64.
2005-06-03 13:30:10 +00:00
matt
25a0e29a75 When writing coredumps, don't write zero uninstantiated demand-zero pages.
Also, with ELF core dumps, trim trailing zeroes from sections.  These two
changes can shrink coredumps by over 50% in size.
2005-06-02 17:01:43 +00:00
explorer
48c9742722 restore NetBSD RCS tag in __KERNEL_RCSID() macro 2005-06-02 15:48:11 +00:00
tron
a40b37b948 Change first argument of m_copydata() back to "struct mbuf *" because
m_copydata() might eventually modify the "mbuf" structure to support
lazy mbuf mapping as pointed out by YAMAMOTO Takashi on "tech-net".
2005-06-02 15:19:28 +00:00
tron
c4f68c0d95 Add missing RCS id. Problem pointed out by Jukka Salmi. 2005-06-02 12:58:16 +00:00
tron
f0abca45e5 Fix bad botch invented in last change. 2005-06-02 12:42:10 +00:00
tron
c54394a240 Change the first argument of m_copydata() to "const struct mbuf *" (which
doesn't require any implementation changes). This will allow us to get
rid off a lot of nasty type casts.
2005-06-02 10:34:59 +00:00
blymn
92bd9a35e9 Fix function variable names shadowing global declarations. 2005-06-01 13:12:49 +00:00
drochner
49d230fa91 need a "const" 2005-06-01 12:27:15 +00:00
chs
3f15e64c3c rename "kbucket" to "kmembuckets", for greater clarity.
don't forget to update vmstat this time.
2005-05-30 23:04:53 +00:00
christos
05e9e5eae6 rename delay. 2005-05-30 22:15:38 +00:00
thorpej
749453ad62 This copy of genassym.sh is now obsolete. PR toolchain/30350 2005-05-30 15:56:47 +00:00
martin
0621296675 Close additional file descriptors if we set MSG_CTRUNC in a SCM_RIGHTS
message. From der Mouse in PR kern/30370.
2005-05-30 11:21:11 +00:00
christos
f63d439f2a finish bucket -> kbucket change 2005-05-30 04:15:17 +00:00
christos
efb6943313 - add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.
2005-05-29 22:24:14 +00:00
christos
6639138da1 Now we can fix the volatile cast-aways.
Rename some shadowed variables while here.
2005-05-29 21:16:14 +00:00
christos
b636cdfe8a Regen 2005-05-29 21:11:30 +00:00
christos
44285e060d Argument for swapctl cannot be const, since it gets loaded with swap
statistics.
2005-05-29 21:07:49 +00:00
elad
686a5b23f6 Make veriexec_fp_cmp() a bit more useful by allowing it to compare two
fingerprints based on a common algorithm without requiring an actual
entry in the tables.
2005-05-29 16:07:10 +00:00
elad
65b04a0bf1 Use PAGE_SIZE chunks, not VERIEXEC_BUFSIZE - it's very important that the
size is not arbitrary and is exactly the size of a page.
2005-05-28 16:37:20 +00:00
elad
dbc8605f39 - Add VERIEXEC_OPINIT() and veriexec_add_fp_ops(), simplifying the addition
of fingerprinting algorithms to the ops vector.

- Cleanup in veriexec_add_fp_name().

- Remove veriexec_default_ops and use the above API for adding the default
  methods in veriexec_init_fp_ops().
2005-05-28 15:49:36 +00:00
elad
a2c658e922 Add indication for number of fingerprinted files on each device.
When a table is created for a new device, a new variable is created
under the kern.veriexec.count node named "dev_<id>". For example,
dev_0, dev_3, etc.
2005-05-22 22:34:01 +00:00
christos
7cdea212c0 No 0x in front of %p... 2005-05-22 15:54:45 +00:00
wrstuden
6336cd3696 The file being closed is (fdp->fd_lastfile - i), not i. So compare
(fdp->fd_lastfile - i) against fd_knlistsize. Otherwise we can
call knote_fdclose() on a file descriptor that doesn't have a knote.

This issue explains random panics I have had on process exit over the
past few years.
2005-05-20 16:13:00 +00:00
elad
5888b16eef Some changes in veriexec.
New features:

  - Add a veriexec_report() routine to make most reporting consistent and
    remove some common code.
  - Add 'strict' mode that controls how veriexec behaves.
  - Add sysctl knobs:
     o kern.veriexec.verbose controls verbosity levels. Value: 0, 1.
     o kern.veriexec.strict controls strict level. Values: 0, 1, 2. See
       documentation in sysctl(3) for details.
     o kern.veriexec.algorithms returns a string with a space separated
       list of supported hashing algorithms in veriexec.
  - Updated documentation in man pages for sysctl(3) and sysctl(8).

Bug fixes:

  - veriexec_removechk(): Code cleanup + handle FINGERPRINT_NOTEVAL
    correctly.
  - exec_script(): Don't pass 0 as flag when executing a script; use the
    defined VERIEXEC_INDIRECT - which is 1. Makes indirect execution
    enforcement work.
  - Fix some printing formats and types..
2005-05-19 20:16:19 +00:00
cube
9a1ab71f5f Add P_CLDSIGIGN, P_NOCLDSTOP and P_NOCLDWAIT to the list of flags we want
to inherit from the parent process.
2005-05-17 19:22:19 +00:00
christos
362a4a0bd5 Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
2005-05-17 04:14:57 +00:00
christos
6919a4b65c don't unlock twice. 2005-05-09 23:40:20 +00:00
christos
3b37af53b0 lock all uses of uidhash. provide macros to lock and unlock. based on more
discussions with yamt.
2005-05-09 11:10:07 +00:00
christos
0c55badfae Protect chgsbsize() with splsoftnet(). As discussed with yamt. 2005-05-09 03:27:21 +00:00
christos
8dc75b1c08 Panic strings should not end with \n. 2005-05-08 18:44:39 +00:00
christos
761bd09636 PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.
2005-05-07 17:42:09 +00:00
martin
e8c879147d In m_pulldown avoid a prepend to the next mbuf in the chain if the result
would still not have all data we want continous.
Fixes PR kern/30098.
2005-05-06 09:40:40 +00:00
manu
89647c7ca6 First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
2005-05-03 16:26:27 +00:00