Commit Graph

1593 Commits

Author SHA1 Message Date
martin 567f8e3fe9 Do not truncate the last char from a remote error message 2006-11-01 12:10:06 +00:00
yamt d566a2d50f make agr headers include lock.h and queue.h by themselves. 2006-10-29 22:14:14 +00:00
yamt fb3b846458 agr_setconfig: ensure ifname is NUL terminated. PR/34894 from Michael Pounov. 2006-10-29 11:38:56 +00:00
christos 78a48d28a3 Use strncpy to copy out interface names so that the trailing part of the
buffer is zeroed, and check for overflow.
2006-10-27 15:33:11 +00:00
elad 74482de29f Kill a couple of KAUTH_GENERIC_ISSUSER usages.
I had to refactor the code a bit, I hope it's okay.
2006-10-26 15:11:22 +00:00
elad f808f29d05 Kill KAUTH_GENERIC_ISSUSER use. 2006-10-25 22:56:14 +00:00
elad adf8d7aab2 Introduce KAUTH_REQ_NETWORK_SOCKET_OPEN, to check if opening a socket is
allowed. It takes three int * arguments indicating domain, type, and
protocol. Replace previous KAUTH_REQ_NETWORK_SOCKET_RAWSOCK with it (but
keep it still).

Places that used to explicitly check for privileged context now don't
need it anymore, so I replaced these with XXX comment indiacting it for
future reference.

Documented and updated examples as well.
2006-10-25 22:49:22 +00:00
elad 0a57b5966b Kill some KAUTH_GENERIC_ISSUSER uses. 2006-10-25 20:28:45 +00:00
christos a4b205c85a don't leak kernel variable declarations to userland. 2006-10-22 20:55:09 +00:00
christos 1536848b53 fix typo. 2006-10-22 19:21:26 +00:00
christos f6c67772ca use strlcpy instead of strncpy or bcopy to copy the interface name. 2006-10-22 18:24:02 +00:00
pooka 80b7c62e48 be appropriately const poisonous 2006-10-22 13:25:54 +00:00
uebayasi 3d643c0f73 const static -> static const 2006-10-22 03:39:43 +00:00
dogcow 372e6ef309 now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
2006-10-17 18:21:29 +00:00
dyoung ca38b620b0 Two bug fixes:
If gre_socreate1() cannot find out the socket's address, exit with
an error.  Before, it could exit *without* an error.

If gre_thread1() finds that it is without a valid socket (i.e., so
== NULL) but the configuration is "unchanged" (in initial state),
force reconfiguration.  This prevents a crash when we try to bring
up a GRE over UDP interface whose UDP endpoints have never been
specified.
2006-10-15 06:36:54 +00:00
dyoung 755be14a30 Cosmetic: join lines to conserve vertical space. 2006-10-15 06:28:53 +00:00
dogcow 2023789a40 More -Wunused fallout. sprinkle __unused when possible; otherwise, use the
do { if (&x) {} } while (/* CONSTCOND */ 0);
construct as suggested by uwe in <20061012224845.GA9449@snark.ptc.spbu.ru>.
2006-10-13 16:53:35 +00:00
hannken 1dac4c24ec More __unused (COMPAT_OSOCK not defined). 2006-10-13 10:29:41 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
dyoung 52f0206b50 Bug fix: do not try to destroy a NULL socket. Stops the kernel
from crashing when a GRE over UDP instance of gre(4) is destroyed
before its socket is created/delegated.
2006-10-09 17:54:23 +00:00
peter 9fc3877a2a Remove unneeded usage of LIST_*.
ok cube@
2006-10-09 10:46:00 +00:00
martin 0efa9c8ed3 Make lo* always have the IFF_RUNNING flag set, to apease some
SNMP apps. Fixes PR kern/11830.
2006-10-08 23:19:32 +00:00
tls 8cc016b4bc Protect calls to pool_put/pool_get that may occur in interrupt context
with spl used to protect other allocations and frees, or datastructure
element insertion and removal, in adjacent code.

It is almost unquestionably the case that some of the spl()/splx() calls
added here are superfluous, but it really seems wrong to see:

	s=splfoo();
	/* frob data structure */
	splx(s);
	pool_put(x);

and if we think we need to protect the first operation, then it is hard
to see why we should not think we need to protect the next.  "Better
safe than sorry".

It is also almost unquestionably the case that I missed some pool
gets/puts from interrupt context with my strategy for finding these
calls; use of PR_NOWAIT is a strong hint that a pool may be used from
interrupt context but many callers in the kernel pass a "can wait/can't
wait" flag down such that my searches might not have found them.  One
notable area that needs to be looked at is pf.

See also:

http://mail-index.netbsd.org/tech-kern/2006/07/19/0003.html
http://mail-index.netbsd.org/tech-kern/2006/07/19/0009.html
2006-10-05 17:35:19 +00:00
oster 75642ab7ae It is not sufficient for MINDEX to just 'return 0' if the MINDEX macro
is going to be used from within m_xhalf() and m_xword().  In using
MINDEX in those cases, we must set *err to '1' *before* calling MINDEX
just in case MINDEX does decide to 'return', and causes the function
to return 0 with an un-set err value.  A consequence of this fix is
that we can cleanup a couple of (now) unneeded goto's.  Problem found
by inspection whilst searching for the cause of a different panic.

Also: pavel@ noted the following:
				if (merr != 0)
 					return 0;
was missing from after a call to m_xhalf(), so fix that too.

src/regress/sys/net/bpf/out-of-bounds now passes the regression test.

Ok'ed by pavel@.
2006-10-04 20:47:43 +00:00
elad 51afb61202 PR/19795: Joel Wilsson: net_osdep.h is lying.
Sync comment with reality, thanks for the patch!
2006-09-23 15:17:58 +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 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
dogcow f2d329dca0 remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP. 2006-09-07 02:40:31 +00:00
dyoung 8db36d06c3 Don't use IFQ_ macros on an ifqueue. Fixes a compilation error
reported by christos.
2006-09-03 06:10:06 +00:00
christos 44dddc087f use c99 initializers 2006-09-03 05:08:18 +00:00
cube 207af46910 Add a note about the use of CTL_CREATE in sysctl_createv, otherwise the
code can be confusing.
2006-09-01 16:28:53 +00:00
dyoung 9cc1c09a17 Rename gre_softc member sc_sp to sc_soparm to fix NetBSD/alpha
compiles, where some other system header #defines sc_sp.

In gre_ioctl, GREDSOCK case, do not try to delete sc_fp if it is
NULL.

Move GREDSOCK and GRESSOCK definitions to where the other GRE ioctls
are defined.

Remove #ifdef GRESSOCK, it's unnecessary now that the feature is
complete.
2006-09-01 01:34:05 +00:00
dyoung 47be766fd3 Add a mode to gre(4) that sends GRE tunnel packets in UDP datagrams.
Fix MOBILE encapsulation.  Add many debugging printfs (mainly
concerning UDP mode).  Clean up the gre(4) code a bit.  Add the
capability to setup UDP tunnels to ifconfig.  Update documentation.

In UDP mode, gre(4) puts a GRE header onto transmitted packets,
and hands them to a UDP socket for transmission.  That is, the
encapsulation looks like this: IP+UDP+GRE+encapsulated packet.

There are two ways to set up a UDP tunnel.  One way is to tell the
source and destination IP+port to gre(4), and let gre(4) create
the socket.  The other way to create a UDP tunnel is for userland
to "delegate" a UDP socket to the kernel.
2006-08-31 17:46:16 +00:00
christos 514b3fccd7 fix initializer 2006-08-30 17:00:15 +00:00
christos 378a57007e fix initializers. 2006-08-30 16:58:38 +00:00
christos 3ed5fa0441 Fix initializers. 2006-08-30 16:57:59 +00:00
christos a3b3beb093 fully initialize IF_CLONE_INITIALIZER 2006-08-30 16:41:08 +00:00
christos 6d637b500d add missing initializer 2006-08-28 00:09:28 +00:00
matt 6c8fa3224e One step closer to loadable domains. Store pointers to a domain's soft
interrupt queues so if_detach can remove packets to removed interfaces from
them.  This eliminates a lot of conditional ugly code in if.c
2006-08-25 19:33:50 +00:00
adrianp 3d8cbc06ba A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.

Issue found by pavel@
Fix from martin@

This is SA2006-019 (CVE-2006-4304)
2006-08-23 20:02:23 +00:00
pavel 8bf13164fe defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS. 2006-08-05 17:20:54 +00:00
martin f1dc5b61db Fix typo in comment 2006-08-04 23:18:53 +00:00
christos 224c697f91 Patch from Dheeraj S, inspired by the following FreeBSD change:
Rather than calling mircotime() in catchpacket(), make catchpacket()
take a timeval indicating when the packet was captured. Move
microtime() to the calling functions and grab the timestamp as soon
as we know that we're going to call catchpacket at least once.

This means that we call microtime() once per matched packet, as
opposed to once per matched packet per bpf listener. It also means
that we return the same timestamp to all bpf listeners, rather than
slightly different ones.

It would be more accurate to call microtime() even earlier for all
packets, as you have to grab (1+#listener) locks before you can
determine if the packet will be logged. You could always grab a
timestamp before the locks, but microtime() can be costly, so this
didn't seem like a good idea.

(I guess most ethernet interfaces will have a bpf listener these
days because of dhclient. That means that we could be doing two bpf
locks on most packets going through the interface.)
2006-07-26 13:54:13 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
martin dee43775e6 Small simplification, pointed out by Christian Hattemer in private mail. 2006-07-13 23:43:13 +00:00
martin 81b2f47532 Do not automagically UP the interface when setting the address.
Together with previous ifconfig changes, this fixes PR 30694, at
least for pppoe (and other sppp based) interfaces.
2006-07-13 14:04:50 +00:00
tsutsui 79d3d94bff KNF. 2006-07-08 18:32:53 +00:00
yamt 7d19947ffd make a multiple inclusion protection macro match with the filename. 2006-07-08 05:57:41 +00:00
yamt 85d844ab45 agr_ioctl: wrap a long line after kauth merge. 2006-07-08 05:56:48 +00:00
tron d700257e96 Make this build with GCC 4.x. 2006-06-27 10:45:09 +00:00