Subject: CVS commit: [netbsd-4] src
To: None <source-changes@NetBSD.org>
From: Juan Romero Pardines <xtraeme@netbsd.org>
List: source-changes
Date: 09/27/2007 16:16:32
Module Name:	src
Committed By:	xtraeme
Date:		Thu Sep 27 16:16:32 UTC 2007

Modified Files:
	src/common/include/prop [netbsd-4]: Makefile prop_array.h prop_bool.h
	    prop_data.h prop_dictionary.h prop_ingest.h prop_number.h
	    prop_object.h prop_string.h proplib.h
	src/common/lib/libprop [netbsd-4]: Makefile.inc prop_array.c
	    prop_bool.c prop_data.c prop_dictionary.c prop_dictionary_util.c
	    prop_ingest.c prop_kern.c prop_number.c prop_object.c
	    prop_object_impl.h prop_rb.c prop_string.c
	src/distrib/sets/lists/comp [netbsd-4]: mi
	src/sys/sys [netbsd-4]: dkio.h
	src/usr.sbin/btdevctl [netbsd-4]: btdevctl.c db.c print.c sdp.c
Added Files:
	src/common/include/prop [netbsd-4]: plistref.h
	src/common/lib/libprop [netbsd-4]: prop_stack.c prop_stack.h

Log Message:
Pull up following revision(s) (requested by joerg in ticket #904):
	sbin/veriexecctl/veriexecctl.c: revision 1.29 (via patch)
	common/lib/libprop/prop_string.c: revision 1.9 (via patch)
	distrib/sets/lists/comp/mi: revision 1.1063 (via patch)
	common/lib/libprop/prop_kern.c: revision 1.8 (via patch)
	common/include/prop/prop_string.h: revision 1.2 (via patch)
	common/include/prop/prop_ingest.h: revision 1.2 (via patch)
	usr.sbin/btdevctl/btdevctl.c: revision 1.5 (via patch)
	common/lib/libprop/prop_object_impl.h: revision 1.14 (via patch)
	common/lib/libprop/prop_rb.c: revision 1.7 (via patch)
	common/include/prop/prop_array.h: revision 1.5 (via patch)
	common/lib/libprop/prop_stack.h: revision 1.1 (via patch)
	common/lib/libprop/prop_object_impl.h: revision 1.16 (via patch)
	common/lib/libprop/prop_number.3: revision 1.7 (via patch)
	common/lib/libprop/prop_stack.h: revision 1.2 (via patch)
	common/lib/libprop/prop_stack.c: revision 1.1 (via patch)
	common/lib/libprop/prop_object_impl.h: revision 1.17 (via patch)
	common/lib/libprop/prop_dictionary_util.c: revision 1.2 (via patch)
	common/lib/libprop/prop_dictionary_util.3: revision 1.2 (via patch)
	common/lib/libprop/prop_dictionary.c: revision 1.18 (via patch)
	common/lib/libprop/prop_stack.c: revision 1.2 (via patch)
	common/lib/libprop/prop_object_impl.h: revision 1.18 (via patch)
	common/lib/libprop/prop_dictionary.c: revision 1.19 (via patch)
	common/include/prop/prop_bool.h: revision 1.3 (via patch)
	common/include/prop/prop_dictionary.h: revision 1.7 (via patch)
	common/include/prop/prop_data.h: revision 1.2 (via patch)
	sys/sys/dkio.h: revision 1.14 (via patch)
	usr.sbin/btdevctl/sdp.c: revision 1.4 (via patch)
	common/include/prop/Makefile: revision 1.3 (via patch)
	common/include/prop/prop_number.h: revision 1.5 (via patch)
	common/lib/libprop/prop_object.c: revision 1.14 (via patch)
	common/lib/libprop/prop_object.c: revision 1.15 (via patch)
	common/lib/libprop/prop_object.c: revision 1.16 (via patch)
	common/lib/libprop/prop_bool.3: revision 1.3 (via patch)
	common/lib/libprop/prop_data.3: revision 1.4 (via patch)
	common/lib/libprop/prop_object.3: revision 1.6 (via patch)
	common/lib/libprop/prop_data.c: revision 1.7 (via patch)
	common/lib/libprop/prop_data.c: revision 1.8 (via patch)
	common/lib/libprop/prop_data.c: revision 1.9 (via patch)
	common/lib/libprop/prop_dictionary.c: revision 1.20 (via patch)
	usr.sbin/btdevctl/print.c: revision 1.9 (via patch)
	sbin/veriexecctl/veriexecctl_parse.y: revision 1.22 (via patch)
	common/lib/libprop/prop_number.c: revision 1.12 (via patch)
	common/include/prop/proplib.h: revision 1.5 (via patch)
	common/lib/libprop/prop_number.c: revision 1.13 (via patch)
	common/lib/libprop/prop_number.c: revision 1.14 (via patch)
	common/include/prop/prop_object.h: revision 1.5 (via patch)
	common/lib/libprop/prop_array.3: revision 1.5 (via patch)
	common/include/prop/prop_object.h: revision 1.6 (via patch)
	common/lib/libprop/prop_string.3: revision 1.4 (via patch)
	common/lib/libprop/prop_bool.c: revision 1.10 (via patch)
	common/lib/libprop/Makefile.inc: revision 1.6 (via patch)
	common/lib/libprop/prop_ingest.c: revision 1.2 (via patch)
	common/lib/libprop/prop_bool.c: revision 1.11 (via patch)
	common/lib/libprop/prop_array.c: revision 1.10 (via patch)
	common/lib/libprop/prop_ingest.3: revision 1.3 (via patch)
	common/lib/libprop/prop_bool.c: revision 1.12 (via patch)
	common/lib/libprop/prop_array.c: revision 1.11 (via patch)
	common/lib/libprop/prop_string.c: revision 1.7 (via patch)
	common/lib/libprop/prop_dictionary.3: revision 1.8 (via patch)
	common/lib/libprop/prop_array.c: revision 1.9 (via patch)
	usr.sbin/btdevctl/db.c: revision 1.4 (via patch)
	common/lib/libprop/prop_string.c: revision 1.8 (via patch)
	common/include/prop/plistref.h: revision 1.1 (via patch)
Consider '\r' to be white space. Discussed with and also kept as local
change by freza. With this change, DOS style line endings work.

boolean_t -> bool
TRUE -> true
FALSE -> false

libprop is currently using a recursive parser. While this is fine for
userland, deeply nested arrays and dictionaries can easily overflow
the kernel stack and thereby force a panic.

Fix the internalizer and prop_object_release to use a separate call
stack and alter the dictionary and array handling to not recurse on
the C stack. The default stack has an inline depth of 16 elements,
which should keep the overhead reasonable.

This issue was found by Pavel Cahyna and Jachym Holecek.

Additionally add a limit for prop_object_copyin_ioctl to prevent user
programs from temporary allocating unbound amount of kernel memory.

Allow malloc to fail so that tight loops of userland processes can't
force panics by exhausting the kernel map.

Tested with the sample exploit of Jachym, his test suite and reviewed
by himself (initial patch), Christos Zoulas and Jason Thorpe.
struct plistref does not reference other proplib data types, so split it
in its own header file to be included by dkio.h. Fixes breakage due to
pollution from proplib.h in programs which include ioctl.h. Tested and OK
by dogcow@.

Attempt at fixing build failures after proplib was converted to bool:
FALSE -> false, TRUE -> true, boolean_t -> bool, int -> bool when
appropriate, include stdbool.h . proplib.h no longer provides boolean_t,
so it is necessary to change to bool.
From Tom Spindler (dogcow@).

Avoid using unbound amount of stack frames in prop_object_equal
by using a dynamic stack as well. Reorder arguments for the internalizer
as the iteration is always present and should go before possibly
NULL arguments.
Reviewed by mjf@ and adrianp@


To generate a diff of this commit:
cvs rdiff -r1.2 -r1.2.4.1 src/common/include/prop/Makefile
cvs rdiff -r0 -r1.1.4.2 src/common/include/prop/plistref.h
cvs rdiff -r1.4 -r1.4.4.1 src/common/include/prop/prop_array.h \
    src/common/include/prop/prop_number.h \
    src/common/include/prop/prop_object.h src/common/include/prop/proplib.h
cvs rdiff -r1.2 -r1.2.6.1 src/common/include/prop/prop_bool.h
cvs rdiff -r1.1 -r1.1.6.1 src/common/include/prop/prop_data.h \
    src/common/include/prop/prop_ingest.h \
    src/common/include/prop/prop_string.h
cvs rdiff -r1.6 -r1.6.4.1 src/common/include/prop/prop_dictionary.h
cvs rdiff -r1.5 -r1.5.4.1 src/common/lib/libprop/Makefile.inc \
    src/common/lib/libprop/prop_data.c
cvs rdiff -r1.7 -r1.7.4.1 src/common/lib/libprop/prop_array.c
cvs rdiff -r1.9 -r1.9.4.1 src/common/lib/libprop/prop_bool.c
cvs rdiff -r1.16 -r1.16.4.1 src/common/lib/libprop/prop_dictionary.c
cvs rdiff -r1.1 -r1.1.4.1 src/common/lib/libprop/prop_dictionary_util.c
cvs rdiff -r1.1 -r1.1.6.1 src/common/lib/libprop/prop_ingest.c
cvs rdiff -r1.7 -r1.7.2.1 src/common/lib/libprop/prop_kern.c
cvs rdiff -r1.11 -r1.11.4.1 src/common/lib/libprop/prop_number.c \
    src/common/lib/libprop/prop_object_impl.h
cvs rdiff -r1.12 -r1.12.4.1 src/common/lib/libprop/prop_object.c
cvs rdiff -r1.6 -r1.6.4.1 src/common/lib/libprop/prop_rb.c \
    src/common/lib/libprop/prop_string.c
cvs rdiff -r0 -r1.2.2.2 src/common/lib/libprop/prop_stack.c \
    src/common/lib/libprop/prop_stack.h
cvs rdiff -r1.981.2.5 -r1.981.2.6 src/distrib/sets/lists/comp/mi
cvs rdiff -r1.13 -r1.13.2.1 src/sys/sys/dkio.h
cvs rdiff -r1.3.2.1 -r1.3.2.2 src/usr.sbin/btdevctl/btdevctl.c
cvs rdiff -r1.1.4.1 -r1.1.4.2 src/usr.sbin/btdevctl/db.c \
    src/usr.sbin/btdevctl/sdp.c
cvs rdiff -r1.7.2.1 -r1.7.2.2 src/usr.sbin/btdevctl/print.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.