Commit Graph

1182 Commits

Author SHA1 Message Date
Bruce Evans
d8a4f230d5 Use OID_AUTO instead of magic number for old sysctl debug.elf_trace. The
magic number conflicted with the one for the Lite2 sysctl debug.busyprt.

Staticized some variables.

Removed unused #includes.
1997-04-01 10:41:48 +00:00
Bruce Evans
7f725eacc1 Use OID_AUTO instead of a magic number for Lite2 sysctl debug.lockf_debug.
Removed unused #includes.
1997-04-01 10:30:06 +00:00
Bruce Evans
6898627ce2 Fixed commented-out Lite2 sysctl debug.lockpausetime.
Removed unused #includes.
1997-04-01 10:18:51 +00:00
Bruce Evans
3f39dbc52d Removed potentially harmful garbage <vm/lock.h> and fixed bogus
use of it.  It was actually harmless because the use was null due
to fortuitous include orders and identical (wrong) idempotency
macros.
1997-04-01 08:39:07 +00:00
Peter Wemm
b67cbc6548 Implement code for an OpenBSD-style issetuigid().
This is valueable for library code which needs to be able to find out
whether the current process is or *was* set[ug]id at some point in the
past, and may have a "tainted" execution environment.  This is especially
a problem with the trend to immediately revoke privs at startup and regain
them for critical sections.  One problem with this is that if a cracker
is able to compromise the program while it's still got a saved id, the
cracker can direct the program to regain the privs.  Another problem is
that the user may be able to affect the program in some other way (eg:
setting resolver host aliases) and the library code needs to know when it
should disable these sorts of features.

Reviewed by: ache
Inspired by: OpenBSD (but with a different implementation)
1997-03-31 15:13:33 +00:00
Peter Wemm
7ec6369d7e Regenerate (added issetugid) 1997-03-31 14:55:05 +00:00
Peter Wemm
56f12a6cb5 issetugid is now implemented rather than reserved 1997-03-31 14:52:50 +00:00
Peter Wemm
a89a5370c5 Do not set the P_SUGID flag in seteuid()/setegid() if nothing has changed.
(for supporting issetugid())

Reviewed by: ache  (as was the previous commit, rev 1.29)
1997-03-31 13:47:00 +00:00
Peter Wemm
229a15f084 Do not set the P_SUGID flag in seteuid()/setegid() if nothing has changed.
(for supporting issetugid())
1997-03-31 13:41:49 +00:00
Peter Wemm
a08f4bf601 Fully implement the clause in Appendix B.4.2.2 from Posix 1003.1
that allows traditional BSD setuid/setgid behavior.

The only visible difference should be that a non-root setuid program
(eg: inn's "rnews" program) that is setuid to news, can completely
"become" uid news. (ie: setuid(geteuid())  This was allowed in
traditional 4.2/4.3BSD and is now "blessed" by Posix as a special
case of "appropriate privilige".

Also, be much more careful with the P_SUGID flag so that we can use it
for issetugid() - only set it if something changed.

Reviewed by: ache
1997-03-31 13:36:46 +00:00
Peter Wemm
8a5d815aa0 Make setgroups(0, xxx) behave as it does on SYSV, namely clear the groups
vector except for the egid in groups[0].  There is a risk that programs
that come from SYSV/Linux that expect this to work and don't check for
error returns may accidently pass root's groups on to child processes.

We now do what is least suprising (to non BSD programs/programmers) in
this scenario, and nothing is changed for programs written with BSD groups
rules in mind.

Reviewed by: ache
1997-03-31 13:21:37 +00:00
David Greenman
a91b87211d In accept1(), falloc() is called after the process has awoken, but prior
to removing the connection from the queue. The problem here is that
falloc() may block and this would allow another process to accept the
connection instead. If this happens to leave the queue empty, then the
system will panic with an "accept: nothing queued".

Also changed a wakeup() to a wakeup_one() to avoid the "thundering herd"
problem on new connections in Apache (or any other application that has
multiple processes blocked in accept() for the same socket).
1997-03-31 12:30:01 +00:00
Peter Wemm
57862eed22 Code to do lchown(2), copied from chown(2) except it's NOFOLLOW in ND_INIT
instead of FOLLOW.
1997-03-31 12:21:37 +00:00
Peter Wemm
f77da2867a Regenerate 1997-03-31 12:17:45 +00:00
Peter Wemm
4eb542c64b Reserve 252 (poll, first in OpenBSD)
Reserve 253 (issetugid, as in OpenBSD)
Allocate 254 for lchown(2)
1997-03-31 12:14:48 +00:00
Peter Wemm
6c14d95d0d Treat symlinks as first class citizens with their own uid/gid rather than
as shadows of their containing directory.  This should solve the problem
of users not being able to delete their symlinks from /tmp once and for
all.

Symlinks do not have modes though, they are accessable to everything that
can read the directory (as before).  They are made to show this fact at
lstat time (they appear as mode 0777 always, since that's how the the
lookup routines in the kernel treat them).

More commits will follow, eg: add a real lchown() syscall and man pages.
1997-03-31 12:02:53 +00:00
David Greenman
9caaadb63a Changed the way that the exec image header is read to be filesystem-
centric rather than VM-centric to fix a problem with errors not being
detectable when the header is read.
Killed exech_map as a result of these changes.
There appears to be no performance difference with this change.
1997-03-31 11:11:26 +00:00
Peter Wemm
55a278acdd Make sure we touch all the temporary files at startup, because we assume
they were created later on.  This is not the case when processing
syscalls.isc in the ibcs2 area.  (It generates no declarations, it's
all either hidden (already prototyped elsewhere) or unimplemented).
1997-03-29 11:11:18 +00:00
Peter Wemm
17a8bb9de0 Add missing $Id$
Note; the RCS file has also been reconstructed to have a CSRG vendor branch.
1997-03-25 17:11:30 +00:00
Peter Wemm
356b94e0d3 Replace original rev 1.3; Author: bde; Date: 1997/02/25 17:24:43;
Fix counting of simplelocks in SIMPLELOCK_DEBUG
Fix style regression
1997-03-25 16:38:01 +00:00
Peter Wemm
4bdb9b1168 Replace original rev 1.2; Author: mpp; Date: 1997/02/12 06:52:30
Add missing #include <sys/systm.h>
1997-03-25 16:36:35 +00:00
Peter Wemm
a1ce9d5c33 Replace original revision 1.1; Author dyson; Date: 1997/02/10 02:28:15
Changes from Lite2:
- DEBUG -> SIMPLELOCK_DEBUG
- cosmetic fixes
- bzero of lock at init time -> explicit init of members.
1997-03-25 16:32:46 +00:00
Peter Wemm
6f3ca62e56 This commit was generated by cvs2svn to compensate for changes in r24269,
which included commits to RCS files with non-trunk default branches.
1997-03-25 16:27:20 +00:00
Peter Wemm
53bf4bb2cf Import 4.4BSD-Lite2 onto CSRG branch 1997-03-25 16:27:20 +00:00
Bruce Evans
afd2f6c218 Don't include <sys/ioctl.h> in the kernel. Stage 5: include
<sys/ioctl_compat.h> and sometimes <sys/filio.h> instead of
<sys/ioctl.h> in tty-related files.  <sys/ttycom.h> is still
usually imported bogusly via <sys/termios.h>.
1997-03-24 12:03:06 +00:00
Bruce Evans
2098241054 Don't include <sys/ioctl.h> in the kernel. Stage 4: include
<sys/ttycom.h> and sometimes <sys/filio.h> instead of <sys/ioctl.h>
in miscellaneous files.  Most of these files have nothing to do
with ttys but need to include <sys/ttycom.h> to get the definitions
of TIOC[SG]PGRP which are (ab)used to convert F[SG]ETOWN fcntls into
ioctls.
1997-03-24 11:52:29 +00:00
Bruce Evans
71455815cc Don't include <sys/ioctl.h> in the kernel. Stage 3: include
<sys/filio.h> instead of <sys/ioctl.h> in non-network non-tty files.
1997-03-24 11:37:53 +00:00
Bruce Evans
fce002fdef Don't include <sys/ioctl.h> in the kernel. Stage 1: don't include
it when it is not used.  In most cases, the reasons for including it
went away when the special ioctl headers became self-sufficient.
1997-03-24 11:25:10 +00:00
Guido van Rooij
8f89943eda Add generation number randomization. Newly created filesystems wil now
automatically have random generation numbers. The kenel way of handling those
also changed. Further it is advised to run fsirand on all your nfs exported
filesystems. the code is mostly copied from OpenBSD, with the randomization
chanegd to use /dev/urandom
Reviewed by:	Garrett
Obtained from: OpenBSD
1997-03-23 20:08:22 +00:00
Bruce Evans
3ac4d1ef0c Don't #include <sys/fcntl.h> in <sys/file.h> if KERNEL is defined.
Fixed everything that depended on getting fcntl.h stuff from the wrong
place.  Most things don't depend on file.h stuff at all.
1997-03-23 03:37:54 +00:00
Mike Pritchard
9a8f4a4c93 Restore Bruce's original comment. It seems that "iff" = if and only if,
and is not a typo.  It is used other places in the kernel, too.
1997-03-22 20:34:21 +00:00
Mike Pritchard
269ebc8621 Fix a typo in a comment of a recent commit. 1997-03-22 16:52:19 +00:00
Bruce Evans
774fce94c0 Removed volatile' from declaration of time', and removed the resulting
null casts.  `time' is nonvolatile for accesses within a region locked
by splclock()/splx().  Accesses outside such a region are invalid, and
splx() must have the side effect of potentially changing all global
variables (since there are hundreds of sort of volatile variables like
`time'), so declaring `time' as volatile didn't have any real benefits.
1997-03-22 08:03:51 +00:00
Bruce Evans
3c81694426 Fixed some invalid (non-atomic) accesses to `time', mostly ones of the
form `tv = time'.  Use a new function gettime().  The current version
just forces atomicicity without fixing precision or efficiency bugs.
Simplified some related valid accesses by using the central function.
1997-03-22 06:53:45 +00:00
Bill Paul
0b788fa1da Add support to sendmsg()/recvmsg() for passing credentials between
processes using AF_LOCAL sockets. This hack is going to be used with
Secure RPC to duplicate a feature of STREAMS which has no real counterpart
in sockets (with STREAMS/TLI, you can apparently use t_getinfo() to learn
UID of a local process on the other side of a transport endpoint).

What happens is this: the client sets up a sendmsg() call with ancillary
data using the SCM_CREDS socket-level control message type. It does not
need to fill in the structure. When the kernel notices the data,
unp_internalize() fills in the cmesgcred structure with the sending
process' credentials (UID, EUID, GID, and ancillary groups). This data
is later delivered to the receiving process. The receiver can then
perform the follwing tests:

- Did the client send ancillary data?
	o Yes, proceed.
	o No, refuse to authenticate the client.

- The the client send data of type SCM_CREDS?
	o Yes, proceed.
	o No, refuse to authenticate the client.

- Is the cmsgcred structure the right size?
	o Yes, proceed.
	o No, signal a possible error.

The receiver can now inspect the credential information and use it to
authenticate the client.
1997-03-21 16:12:32 +00:00
Bruce Evans
444f003cca Fixed null pointer panic in devtotty(). Fixed bounds checking in
devtotty().  devtotty() must check its arg carefully since the arg is
supplied as ioctl data.  This should fix PR3004.

Renamed devtotty() to snpdevtotty().
1997-03-16 19:11:40 +00:00
Bruce Evans
d8d6519c63 Fixed the hash formula. Lite2 doesn't have phashinit(), so Lite2's hash
formula uses `& nchash'.  This is very broken when nchash is a prime
number instead of 1 less than a power of 2, but the Lite2 formula was
merged in.

Merged some cosmetic changes from Lite2, rev.1.21 and Lite1.  The merge
was difficult because the Lite2 code is essentially ours (phk's) except
where Lite2 improved or broke it.

Summary of the Lite2 changes:
- in the copyright, phk's rights have been transferred to the Regents.
  This change should be reviewed.
- nchENOENT went away; the "no" vnode is now simply 0.
- comments were improved.
- style was "improved".
- goto instead of Fanatism (sic) was considered bad :-).
- there are some small changes to support whiteouts.
- new cache entries are added in more cases.  More work is required
  near here to change the hash table size if kern.desiredvnodes is
  changed using sysctl.
- rescanning of the hash bucket in cache_purgevfs() was removed.  This
  change should be reviewed.
1997-03-08 15:22:14 +00:00
Guido van Rooij
dfd0621acc Fix style bugs and other bugs in the NFS fix. 1997-03-08 15:14:30 +00:00
John Dyson
d6faa36b42 Remove unnecessary check for vp->v_mount being null. Pointed
out by BDE.
1997-03-07 14:40:54 +00:00
Gary Palmer
324d42ad57 Fix (I hope) the NFS hole. This is only compile tested.
Submitted by:	(partly) davids@SECNET.COM via BUGTRAQ
1997-03-07 07:42:41 +00:00
Bruce Evans
c68fa33937 Try a no-wait malloc first in clist_alloc_cblocks(). If this fails, then
complain and blunder on.

Should be in 2.2, preferably with a better fix.
1997-03-05 16:45:01 +00:00
David Greenman
2f2160da3b Fixed splbio problems in vinvalbuf. Closes PR#2875, although fixed
differently by me.
1997-03-05 04:54:54 +00:00
Mike Smith
3a558f83dd Check that vp->v_mount is non-null in fsync() before dereferencing it to
obtain the mountpoint's MNT_ASYNC flag.

This is a Very Definite Last-Minute 2.2 Bugfix Candidate.

Reviewed by:	sef
1997-03-05 01:42:14 +00:00
Bruce Evans
4a8b966013 Attach vfs_sysctl() one level lower so that only the levels below
VFS_GENERIC aren't done in the FreeBSD way.  The previous commit
broke the nfs sysctls.
1997-03-04 18:31:56 +00:00
Andrey A. Chernov
53490b7634 Oops, fix typo. 1997-03-03 23:02:43 +00:00
Andrey A. Chernov
30cf3ac460 Don't copy more than MAXLOGNAME bytes in getlogin() syscall,
it is stricter than padded s_login size check was there.
1997-03-03 22:46:16 +00:00
Bruce Evans
3a76a5949b Merged Lite2's vfs_sysctl(). It doesn't fit very well into FreeBSD's
(phk's) sysctl framework, and I needed special code to disambiguate
the VFS_GENERIC node from the VFS_VFSCONF leaf, so I only converted
the leaves to the FreeBSD framework.  The error handling isn't quite
right.  CSRGS's sysctls seem to return ENOTDIR too much and FreeBSD's
sysctls don't agree with the man page.
1997-03-03 12:58:20 +00:00
Andrey A. Chernov
964ca0caee Use MAXLOGNAME for stricter size check in setlogin() syscall instead of
sizeof of padded s_login array
1997-03-03 10:15:48 +00:00
Bruce Evans
dc91a89e83 Restored some pre-Lite2-merge source-level compatibility to the mount()
and getvfsbyname() interfaces.  The new interfaces are now hidden from
applications unless _NEW_VFSCONF is defined.  The new vfsconf interfaces
don't work yet.
1997-03-02 17:53:37 +00:00
Bruce Evans
a896f0256c Moved vfs sysctls to where Lite2 put them. No code changes yet. 1997-03-02 11:06:22 +00:00