summaryrefslogtreecommitdiffstats
path: root/share/man/man9/memguard.9
blob: 72a41e59e5be4415fd774bdedda40eb3cec99f66 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.\" Copyright (c) 2005 Christian Brueffer
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 31, 2006
.Dt MEMGUARD 9
.Os
.Sh NAME
.Nm MemGuard
.Nd "memory allocator for debugging purposes"
.Sh SYNOPSIS
.Cd "options DEBUG_MEMGUARD"
.Sh DESCRIPTION
.Nm
is a simple and small replacement memory allocator designed
to help detect tamper-after-free scenarios.
These problems are more and more common and likely with
multithreaded kernels where race conditions are more prevalent.
.Pp
Currently,
.Nm
can only take over
.Fn malloc ,
.Fn realloc
and
.Fn free
for a particular malloc type.
.Sh EXAMPLES
To use
.Nm
for memory type compiled into the kernel, one has to add the
following line to the
.Pa /boot/loader.conf :
.Bd -literal -offset indent
vm.memguard.desc=<memory_type>
.Ed
.Pp
Where
.Ar memory_type
is a short description of memory type to monitor.
The short description of memory type is the second argument to
.Xr MALLOC_DEFINE 9 ,
so one has to find it in the kernel source.
.Pp
To use
.Nm
for memory type defined in a kernel module, one has to set
.Va vm.memguard.desc
.Xr sysctl 8
variable before loading the module:
.Bd -literal -offset indent
sysctl vm.memguard.desc=<memory_type>
.Ed
.Pp
The
.Va vm.memguard.divisor
boot-time tunable is used to scale how much of
.Va kmem_map
one wants to allocate for
.Nm .
The default is 10, so
.Va kmem_size Ns /10
bytes will be used.
The
.Va kmem_size
value can be obtained via the
.Va vm.kmem_size
.Xr sysctl 8
variable.
.Sh SEE ALSO
.Xr sysctl 8 ,
.Xr vmstat 8 ,
.Xr contigmalloc 9 ,
.Xr malloc 9 ,
.Xr redzone 9
.Sh HISTORY
.Nm
first appeared in
.Fx 6.0 .
.Sh AUTHORS
.An -nosplit
.Nm
was written by
.An Bosko Milekic Aq bmilekic@FreeBSD.org .
This manual page was written by
.An Christian Brueffer Aq brueffer@FreeBSD.org .
.Sh BUGS
Currently, it is not possible to override UMA
.Xr zone 9
allocations.
OpenPOWER on IntegriCloud