blob: 4fbc636db4eeca6aa8c3eefd311b82d039594f40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
portseal - tools to locate port management bugs
===============================================
This is a collection of tools to find bugs related to Mach port
handling like port leaks at runtime.
Requirements
------------
portseal is written in python and leverages coccinelle for the source
transformation. libportseal requires liburcu.
How to use it
-------------
Use "portseal patch" within the source of your target code to patch
it, "portseal unpatch" to undo the change. "make check" demonstrates
how to use portseal and pinniped to find both port leaks and wrong use
of port management functions:
% make check
rm -rf -- test-obj
cp -a test test-obj
(cd test-obj && ../bin/portseal patch)
[...]
bin/pinniped test-obj/test
dosth looked up 146
test-obj/test: leaked send right 146
test-obj/test[0x80489c3]
test-obj/test[0x8048d05]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x10aa69c]
test-obj/test[0x8048811]
dosthelse looked up 148
test-obj/test: leaked send right 148
test-obj/test[0x8048d9d]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x10aa69c]
test-obj/test[0x8048811]
dosthglobal looked up 153
test-obj/test: leaked send right 153
test-obj/test[0x8048dc2]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x10aa69c]
test-obj/test[0x8048811]
allocated receive port 154
test-obj/test: leaked receive right 154
test-obj/test[0x8048c36]
test-obj/test[0x8048dcc]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x10aa69c]
test-obj/test[0x8048811]
dolookupcwd looked up 108
test-obj/test: mach_port_deallocate (1, 12345): (os/kern) invalid name
test-obj/test[0x8048ce0]
test-obj/test[0x8048dd6]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x10aa69c]
test-obj/test[0x8048811]
test-obj/test: mach_port_destroy (1, 54321): (os/kern) invalid name
test-obj/test[0x8048cf5]
test-obj/test[0x8048dd6]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x10aa69c]
test-obj/test[0x8048811]
% addr2line -e test-obj/test 0x8048c36
.../portseal/test-obj/test.c:65
libpinniped
-----------
libpinniped wraps port manipulation functions (i.e. the glibc
wrappers) with the help of the dynamic linker. If any of the wrapped
functions fail, a message is written to stderr with a backtrace.
% make -C libpinniped check
make: Entering directory `.../portseal/libpinniped'
LD_PRELOAD=./"libpinniped.so" ./test
./test: mach_port_deallocate (1, 12345): (os/kern) invalid name
./test(dosth+0x1b)[0x80486c8]
./test(main+0xb)[0x80486f2]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x109169c]
./test[0x80485d1]
./test: mach_port_destroy (1, 54321): (os/kern) invalid name
./test(dosthelse+0x1b)[0x80486e5]
./test(main+0x10)[0x80486f7]
/lib/i386-gnu/libc.so.0.3(__libc_start_main+0xbc)[0x109169c]
./test[0x80485d1]
make: Leaving directory `.../portseal/libpinniped'
% addr2line -e libpinniped/test 0x80486c8
.../portseal/libpinniped/test.c:24
|