Commit Graph

5819 Commits

Author SHA1 Message Date
Andrey A. Chernov
a08f5d95ec 1) Use __packed attr on rdat structure to make it exact 128 bytes.
2) Use gettimeofday() and getpid() only if reading from /dev/urandom
fails or impossible.
3) Discard N bytes on very first initialization only (i.e. don't
discard on re-stir).
4) Reduce N from 1024 to 512 as really suggested in the
"(Not So) Random Shuffles of RC4" paper:
http://research.microsoft.com/users/mironov/papers/rc4full.pdf
2008-07-21 21:57:30 +00:00
Andrey A. Chernov
860c4e582a 1) Update copyright notice.
2) Eliminate "struct arc4_stream *as" arg since only single arg is
possible.
3) Set rs.j = rs.i after arc4random key schedule to be more like arc4
stream cipher.

Obtained from:  OpenBSD
2008-07-21 20:04:32 +00:00
Andrey A. Chernov
531ebdb7b1 Add arc4random_buf to FBSD_1.1 space 2008-07-21 18:03:31 +00:00
Andrey A. Chernov
1c443b9b18 Add arc4random_buf.3 to MLINKS 2008-07-21 14:33:11 +00:00
Andrey A. Chernov
bc6847e225 Implement arc4random_buf() function
Obtained from:  OpenBSD
2008-07-21 13:52:06 +00:00
Andrey A. Chernov
b6634bf8d2 Decrease arc4_count only when needed and with proper bytes amount.
Obtained from:  OpenBSD
2008-07-21 12:44:47 +00:00
Andrey A. Chernov
0761bd1fe1 1) Set stired flag after forced initialization.
2) Increase arc4_count to the limit OpenBSD use.

Submitted by:   Thorsten Glaser <tg@mirbsd.de> (1)
Obtained from:  OpenBSD (2)
2008-07-21 10:31:28 +00:00
Jason Evans
2bb0f7ba54 Enhance arena_chunk_map_t to directly support run coalescing, and use
the chunk map instead of red-black trees where possible.  Remove the
red-black trees and node objects that are obsoleted by this change.  The
net result is a ~1-2% memory savings, and a substantial allocation speed
improvement.
2008-07-18 19:35:44 +00:00
Simon L. B. Nielsen
863a8774c7 Make it more clear what it means that SA_RESTART is set for signal
handlers added with signal(3).

Submitted by:	gnn (slightly modified by me)
MFC after:	1 week
2008-07-17 21:54:23 +00:00
Daniel Gerzo
a624bb23e3 Update the definition of modspecific structure
PR:		docs/125630
2008-07-15 10:06:37 +00:00
Robert Watson
0d01d41007 The libc acl_valid(3) function validates the contents of a POSIX.1e ACL.
This change removes the requirement that an ACL contain no ACL_USER
entries with a uid the same as those of a file, or ACL_GROUP entries
with a gid the same as those of a file.  This requirement is not in the
specification, and not enforced by the kernel's ACL implementation.

Reported by:	Iustin Pop <iusty at k1024 dot org>
MFC after:	1 week
2008-07-13 16:37:51 +00:00
Remko Lodder
5f65888ab9 Update the ktr_header structure, which changed over time.
PR:		125546
Submitted by:	Mateusz Guzik <mjguzik at gmail dot com>
MFC after:	3 days
2008-07-13 13:42:52 +00:00
Brooks Davis
6b794ce8ef Put the _cpuset* symbols in FBSDprivate_1.0 instead of trying to put
nonexistant __cpuset* there.
2008-07-11 15:17:06 +00:00
Daniel Gerzo
5fd5badfa9 - This code was intially obtained from NetBSD, but it's missing licence
statement. Add the one from the current NetBSD version.
- Also bump a date to reflect my content changes I have done in previous
  revision

Approved by:	imp
MFC after:	3 days
2008-07-06 17:03:37 +00:00
Daniel Gerzo
6d05da1dc9 - Add description about a missing return value
PR:		docs/75995
Submitted by:	Tarc <tarc@po.cs.msu.su>
MFC after:	3 days
2008-07-06 12:17:53 +00:00
Daniel Gerzo
408425ce37 - remove superfluous word
- remove contractions

MFC after:	3 days
2008-07-06 11:31:20 +00:00
Daniel Gerzo
05e3085a53 - AI_ALL and AI_V4MAPPED flags are currently not supported
PR:		docs/120248
Submitted by:	Heiko Wundram <wundram (a) beenic.net>
2008-07-01 22:59:20 +00:00
Daniel Gerzo
345f9e9dc7 - Forgot to bump a date after last change 2008-06-30 08:46:09 +00:00
David Schultz
c4014b5086 Fix a bogon in the previous commit and add some missing error checks. 2008-06-29 23:46:06 +00:00
David Schultz
e62e5ff93f Correctly handle malloc() failure. While here, reduce the code size a
bit by removing some calls to the inline function addtype().
2008-06-29 22:54:26 +00:00
David Schultz
07bed96bd3 Factor out the code that builds the argument table. We don't need separate
normal and wide character versions of it.

No functional change.
2008-06-29 22:04:25 +00:00
David Schultz
2591efccfa Reduce the level of duplication between vfprintf() and vfwprintf()
by moving the positional argument handling code to a new file,
printf-pos.c, and moving common definitions to printflocal.h.
No functional change intended.
2008-06-29 21:52:40 +00:00
David Schultz
e5abb5e698 Begin de-spaghettifying the code that handles positional arguments.
In particular, encapsulate the state of the type table in a struct,
and add inline functions to initialize, free, and manipulate that
state. This replaces some ugly macros that made proper error handling
impossible.

While here, remove an unneeded test for NULL and a variable that is
initialized (many times!) but never used. The compiler didn't catch
these because of rampant use of the same variable to mean different
things in different places.

This commit should not cause any changes in functionality.
2008-06-29 21:01:27 +00:00
David Schultz
6b2bbb0465 Make it clearer that it is possible to disable the generation of
SIGPIPE for individual sockets (PR: kern/118626).

While here, s/insure/ensure/.
2008-06-29 17:17:14 +00:00
David Schultz
4110421449 We should also save and restore the MXCSR as on amd64, but detecting
whether the CPU supports SSE or not here is rather odious.
2008-06-28 17:58:06 +00:00
David Schultz
64c2e46650 Two FP-related setjmp/longjmp changes:
1. Save and restore the control part of the MXCSR in addition to the
   i387 control word to ensure that the two are consistent.

   Note that standards don't require longjmp to restore either control
   word, and none of Linux, MacOS X 10.3 and earlier, NetBSD, OpenBSD,
   or Solaris do it. However, it is historical FreeBSD behavior, and
   bde points out that it is needed to make longjmping out of a signal
   handler work properly, given the way FreeBSD clobbers the FPU state
   on signal handler entry.

2. Don't clobber the FPU exception flags in longjmp. C99 requires them
   to remain unchanged.
2008-06-28 17:55:43 +00:00
Daniel Gerzo
aa2a33b4fa - add description of the MLINK error
PR:		docs/123019
MFC after:	3 days
2008-06-26 12:15:38 +00:00
Daniel Gerzo
91bc389e54 Mark the section describing return values with an appropriate section flag.
PR:		docs/122818
MFC after:	3 days
2008-06-26 08:24:59 +00:00
Mike Makonnen
34a087543a Gcc barfs in glob.c when run with -O3. To fix this make g_strchr() work on
and return (const Char *) pointers instead of just (Char *) and get rid of
all the type casting.

PR:		kern/124334
2008-06-26 07:12:35 +00:00
Ruslan Ermilov
042df2e2da Enable GCC stack protection (aka Propolice) for userland:
- It is opt-out for now so as to give it maximum testing, but it may be
  turned opt-in for stable branches depending on the consensus.  You
  can turn it off with WITHOUT_SSP.
- WITHOUT_SSP was previously used to disable the build of GNU libssp.
  It is harmless to steal the knob as SSP symbols have been provided
  by libc for a long time, GNU libssp should not have been much used.
- SSP is disabled in a few corners such as system bootstrap programs
  (sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves.
- It should be safe to use -fstack-protector-all to build world, however
  libc will be automatically downgraded to -fstack-protector because it
  breaks rtld otherwise.
- This option is unavailable on ia64.

Enable GCC stack protection (aka Propolice) for kernel:
- It is opt-out for now so as to give it maximum testing.
- Do not compile your kernel with -fstack-protector-all, it won't work.

Submitted by:	Jeremie Le Hen <jeremie@le-hen.org>
2008-06-25 21:33:28 +00:00
Ed Schouten
c605eea952 Turn execvpe() into an internal libc routine.
Adding exevpe() has caused some ports to break. Even though execvpe() is
a useful routine, it does not conform to any standards.

This patch is a little bit different from the patch sent to the mailing
list. I forgot to remove execvpe from the Symbol.map (which does not
seem to miscompile libc, though).

Reviewed by:	davidxu
Approved by:	philip
2008-06-23 05:22:06 +00:00
Poul-Henning Kamp
20067a6892 Add Xr to getsockname(2) 2008-06-20 14:47:06 +00:00
David Xu
8e9a8a6c78 Process spawn attributes in POSIX document order. 2008-06-19 02:42:50 +00:00
Ed Schouten
e3580e9d91 Don't export the unused __use_pts() routine.
The __use_pts() routine was once probably used by libutil to determine
if we are using BSD or UNIX98 style PTY device names. It doesn't seem to
be used outside grantpt.c, which means we can make it static and remove
it from the Symbol.map.

Reviewed by:	cognet, kib
Approved by:	philip (mentor)
2008-06-17 14:05:03 +00:00
David Xu
fdbeb80a2b Style fix. 2008-06-17 08:23:45 +00:00
Ed Schouten
d1b2bd213c Change my email address to the one from the FreeBSD project.
Approved by:	philip (mentor, implicit), davidxu
2008-06-17 07:09:58 +00:00
David Xu
947aa542e9 Add POSIX routines called posix_spawn() and posix_spawnp(), which
can be used as replacements for exec/fork in a lot of cases. This
change also added execvpe() which allows environment variable
PATH to be used for searching executable file, it is used for
implementing posix_spawnp().

PR: standards/122051
2008-06-17 06:26:29 +00:00
Tony Finch
0cf1d3bf73 Make it clearer that privilege is needed to reduce as well as
increase group membership.
2008-06-16 14:50:21 +00:00
Wojciech A. Koszek
98fbfcd632 Bring missing getsockopt(2) options: SO_LABEL SO_PEERLABEL SO_LISTENQLIMIT
SO_LISTENQLEN SO_LISTENINCQLEN to the manual page.

Till now those were only present in sys/socket.h file.

Reviewed by:	rwatson, gnn, keramida (with mdoc hat)
2008-06-12 22:58:35 +00:00
Jason Evans
b1c8b30f55 In the error path through base_alloc(), release base_mtx [1].
Fix bit vector initialization for run headers.

Submitted by:	[1] Mike Schuster <schuster@adobe.com>
2008-06-10 15:46:18 +00:00
David Xu
83a0758789 Make pthread_cleanup_push() and pthread_cleanup_pop() as a pair of macros,
use stack space to keep cleanup information, this eliminates overhead of
calling malloc() and free() in thread library.

Discussed on: thread@
2008-06-09 01:14:10 +00:00
Doug Rabson
cd7d66a21f Call the fcntl compatiblity wrapper from the thread library fcntl wrappers
so that they get the benefit of the (limited) forward ABI compatibility.

MFC after: 1 week
2008-05-30 14:47:42 +00:00
Doug Rabson
2da0808aec Make fcntl() a weak symbol so that it can be overridden by thread libraries.
MFC after: 2 days
2008-05-27 14:03:32 +00:00
Greg Lehey
b98d401185 Clarify that "ante meridiem" and "post meridiem" mean the same thing
as the more commonly used "a.m." and "p.m.".

Tripped over by:  Callum Gibson.

MFC after:  2 weeks
2008-05-16 04:33:04 +00:00
Jason Evans
2e78350530 Clean up cpp logic and comments. 2008-05-14 18:33:13 +00:00
Antoine Brodin
27522528ea Remove useless call to getdtablesize(2) in fdopen(3) and its useless
variable nofile.

PR:		123109
Submitted by:	Christoph Mallon
Approved by:	rwatson (mentor)
MFC after:	1 month
2008-05-10 18:39:20 +00:00
Christian Brueffer
2e462358ed Misc mdoc improvements and a typo fix. 2008-05-10 07:31:34 +00:00
Julian Elischer
4ba9fdc4a6 Add setfib.2 to the list of man pages to add 2008-05-09 23:09:56 +00:00
Julian Elischer
23c3fd9e62 setfib.2 got left out of the last commit 2008-05-09 23:08:40 +00:00
Julian Elischer
65cb6b6834 Add code to allow the system to handle multiple routing tables.
This particular implementation is designed to be fully backwards compatible
and to be MFC-able to 7.x (and 6.x)

Currently the only protocol that can make use of the multiple tables is IPv4
Similar functionality exists in OpenBSD and Linux.

From my notes:

-----

One thing where FreeBSD has been falling behind, and which by chance I
have some time to work on is "policy based routing", which allows
different
packet streams to be routed by more than just the destination address.

Constraints:
------------

I want to make some form of this available in the 6.x tree
(and by extension 7.x) , but FreeBSD in general needs it so I might as
well do it in -current and back port the portions I need.

One of the ways that this can be done is to have the ability to
instantiate multiple kernel routing tables (which I will now
refer to as "Forwarding Information Bases" or "FIBs" for political
correctness reasons). Which FIB a particular packet uses to make
the next hop decision can be decided by a number of mechanisms.
The policies these mechanisms implement are the "Policies" referred
to in "Policy based routing".

One of the constraints I have if I try to back port this work to
6.x is that it must be implemented as a EXTENSION to the existing
ABIs in 6.x so that third party applications do not need to be
recompiled in timespan of the branch.

This first version will not have some of the bells and whistles that
will come with later versions. It will, for example, be limited to 16
tables in the first commit.
Implementation method, Compatible version. (part 1)
-------------------------------
For this reason I have implemented a "sufficient subset" of a
multiple routing table solution in Perforce, and back-ported it
to 6.x. (also in Perforce though not  always caught up with what I
have done in -current/P4). The subset allows a number of FIBs
to be defined at compile time (8 is sufficient for my purposes in 6.x)
and implements the changes needed to allow IPV4 to use them. I have not
done the changes for ipv6 simply because I do not need it, and I do not
have enough knowledge of ipv6 (e.g. neighbor discovery) needed to do it.

Other protocol families are left untouched and should there be
users with proprietary protocol families, they should continue to work
and be oblivious to the existence of the extra FIBs.

To understand how this is done, one must know that the current FIB
code starts everything off with a single dimensional array of
pointers to FIB head structures (One per protocol family), each of
which in turn points to the trie of routes available to that family.

The basic change in the ABI compatible version of the change is to
extent that array to be a 2 dimensional array, so that
instead of protocol family X looking at rt_tables[X] for the
table it needs, it looks at rt_tables[Y][X] when for all
protocol families except ipv4 Y is always 0.
Code that is unaware of the change always just sees the first row
of the table, which of course looks just like the one dimensional
array that existed before.

The entry points rtrequest(), rtalloc(), rtalloc1(), rtalloc_ign()
are all maintained, but refer only to the first row of the array,
so that existing callers in proprietary protocols can continue to
do the "right thing".
Some new entry points are added, for the exclusive use of ipv4 code
called in_rtrequest(), in_rtalloc(), in_rtalloc1() and in_rtalloc_ign(),
which have an extra argument which refers the code to the correct row.

In addition, there are some new entry points (currently called
rtalloc_fib() and friends) that check the Address family being
looked up and call either rtalloc() (and friends) if the protocol
is not IPv4 forcing the action to row 0 or to the appropriate row
if it IS IPv4 (and that info is available). These are for calling
from code that is not specific to any particular protocol. The way
these are implemented would change in the non ABI preserving code
to be added later.

One feature of the first version of the code is that for ipv4,
the interface routes show up automatically on all the FIBs, so
that no matter what FIB you select you always have the basic
direct attached hosts available to you. (rtinit() does this
automatically).

You CAN delete an interface route from one FIB should you want
to but by default it's there. ARP information is also available
in each FIB. It's assumed that the same machine would have the
same MAC address, regardless of which FIB you are using to get
to it.

This brings us as to how the correct FIB is selected for an outgoing
IPV4 packet.

Firstly, all packets have a FIB associated with them. if nothing
has been done to change it, it will be FIB 0. The FIB is changed
in the following ways.

Packets fall into one of a number of classes.

1/ locally generated packets, coming from a socket/PCB.
   Such packets select a FIB from a number associated with the
   socket/PCB. This in turn is inherited from the process,
   but can be changed by a socket option. The process in turn
   inherits it on fork. I have written a utility call setfib
   that acts a bit like nice..

       setfib -3 ping target.example.com # will use fib 3 for ping.

   It is an obvious extension to make it a property of a jail
   but I have not done so. It can be achieved by combining the setfib and
   jail commands.

2/ packets received on an interface for forwarding.
   By default these packets would use table 0,
   (or possibly a number settable in a sysctl(not yet)).
   but prior to routing the firewall can inspect them (see below).
   (possibly in the future you may be able to associate a FIB
   with packets received on an interface..  An ifconfig arg, but not yet.)

3/ packets inspected by a packet classifier, which can arbitrarily
   associate a fib with it on a packet by packet basis.
   A fib assigned to a packet by a packet classifier
   (such as ipfw) would over-ride a fib associated by
   a more default source. (such as cases 1 or 2).

4/ a tcp listen socket associated with a fib will generate
   accept sockets that are associated with that same fib.

5/ Packets generated in response to some other packet (e.g. reset
   or icmp packets). These should use the FIB associated with the
   packet being reponded to.

6/ Packets generated during encapsulation.
   gif, tun and other tunnel interfaces will encapsulate using the FIB
   that was in effect withthe proces that set up the tunnel.
   thus setfib 1 ifconfig gif0 [tunnel instructions]
   will set the fib for the tunnel to use to be fib 1.

Routing messages would be associated with their
process, and thus select one FIB or another.
messages from the kernel would be associated with the fib they
refer to and would only be received by a routing socket associated
with that fib. (not yet implemented)

In addition Netstat has been edited to be able to cope with the
fact that the array is now 2 dimensional. (It looks in system
memory using libkvm (!)). Old versions of netstat see only the first FIB.

In addition two sysctls are added to give:
a) the number of FIBs compiled in (active)
b) the default FIB of the calling process.

Early testing experience:
-------------------------

Basically our (IronPort's) appliance does this functionality already
using ipfw fwd but that method has some drawbacks.

For example,
It can't fully simulate a routing table because it can't influence the
socket's choice of local address when a connect() is done.

Testing during the generating of these changes has been
remarkably smooth so far. Multiple tables have co-existed
with no notable side effects, and packets have been routes
accordingly.

ipfw has grown 2 new keywords:

setfib N ip from anay to any
count ip from any to any fib N

In pf there seems to be a requirement to be able to give symbolic names to the
fibs but I do not have that capacity. I am not sure if it is required.

SCTP has interestingly enough built in support for this, called VRFs
in Cisco parlance. it will be interesting to see how that handles it
when it suddenly actually does something.

Where to next:
--------------------

After committing the ABI compatible version and MFCing it, I'd
like to proceed in a forward direction in -current. this will
result in some roto-tilling in the routing code.

Firstly: the current code's idea of having a separate tree per
protocol family, all of the same format, and pointed to by the
1 dimensional array is a bit silly. Especially when one considers that
there is code that makes assumptions about every protocol having the
same internal structures there. Some protocols don't WANT that
sort of structure. (for example the whole idea of a netmask is foreign
to appletalk). This needs to be made opaque to the external code.

My suggested first change is to add routing method pointers to the
'domain' structure, along with information pointing the data.
instead of having an array of pointers to uniform structures,
there would be an array pointing to the 'domain' structures
for each protocol address domain (protocol family),
and the methods this reached would be called. The methods would have
an argument that gives FIB number, but the protocol would be free
to ignore it.

When the ABI can be changed it raises the possibilty of the
addition of a fib entry into the "struct route". Currently,
the structure contains the sockaddr of the desination, and the resulting
fib entry. To make this work fully, one could add a fib number
so that given an address and a fib, one can find the third element, the
fib entry.

Interaction with the ARP layer/ LL layer would need to be
revisited as well. Qing Li has been working on this already.

This work was sponsored by Ironport Systems/Cisco

PR:
Reviewed by:	several including rwatson, bz and mlair (parts each)
Approved by:
Obtained from:	Ironport systems/Cisco
MFC after:
Security:

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
Security:
2008-05-09 23:00:21 +00:00