History log of /freebsd-11-stable/share/man/man9/malloc.9
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 328210 21-Jan-2018 kp

MFC r327674, r327796

Introduce mallocarray() in the kernel

Similar to calloc() the mallocarray() function checks for integer
overflows before allocating memory.
It does not zero memory, unless the M_ZERO flag is set.

Additionally, move the overflow check logic out to WOULD_OVERFLOW() for
consumers to have a common means of testing for overflowing allocations.
WOULD_OVERFLOW() should be a secondary check -- on 64-bit platforms, just
because an allocation won't overflow size_t does not mean it is a sane size
to request. Callers should be imposing reasonable allocation limits far,
far, below overflow.

Obtained from: OpenBSD


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 293421 08-Jan-2016 brueffer

Fix issues found by mandoc -Tlint.

MFC after: 1 week


# 291074 19-Nov-2015 jtl

Consistently enforce the restriction against calling malloc/free when in a
critical section.

uma_zalloc_arg()/uma_zalloc_free() may acquire a sleepable lock on the
zone. The malloc() family of functions may call uma_zalloc_arg() or
uma_zalloc_free().

The malloc(9) man page currently claims that free() will never sleep.
It also implies that the malloc() family of functions will not sleep
when called with M_NOWAIT. However, it is more correct to say that
these functions will not sleep indefinitely. Indeed, they may acquire
a sleepable lock. However, a developer may overlook this restriction
because the WITNESS check that catches attempts to call the malloc()
family of functions within a critical section is inconsistenly
applied.

This change clarifies the language of the malloc(9) man page to clarify
the restriction against calling the malloc() family of functions
while in a critical section or holding a spin lock. It also adds
KASSERTs at appropriate points to make the enforcement of this
restriction more consistent.

PR: 204633
Differential Revision: https://reviews.freebsd.org/D4197
Reviewed by: markj
Approved by: gnn (mentor)
Sponsored by: Juniper Networks


# 274925 23-Nov-2014 joel

Misc mdoc fixes:

- Remove superfluous paragraph macros.
- Remove/fix empty or incorrect macros.
- Sort sections into conventional order.
- Terminate quoted strings properly.
- Remove EOL whitespace.


# 260720 16-Jan-2014 glebius

Remove notes about historical mbuf(9) allocator flags from documentation.

Sponsored by: Nginx, Inc.


# 243145 16-Nov-2012 joel

Remove trailing whitespace.


# 243137 16-Nov-2012 alc

M_USE_RESERVE is no longer deprecated. It is once again supported.

Reviewed by: kib


# 238542 17-Jul-2012 kevlo

Put parenthesis around sizeof args.


# 233648 29-Mar-2012 eadler

Remove trailing whitespace per mdoc lint warning

Disussed with: gavin
No objection from: doc
Approved by: joel
MFC after: 3 days


# 230679 28-Jan-2012 kmacy

update .Dd


# 230645 28-Jan-2012 kmacy

document M_NODUMP flag


# 204604 02-Mar-2010 joel

The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from: NetBSD


# 184205 23-Oct-2008 des

Retire the MALLOC and FREE macros. They are an abomination unto style(9).

MFC after: 3 months


# 177608 25-Mar-2008 ru

s/M_TRYWAIT/M_WAIT/


# 142246 22-Feb-2005 brueffer

Xref memguard(9)


# 140561 21-Jan-2005 ru

Sort sections.


# 130843 21-Jun-2004 mpp

Spelling fixes.


# 126682 06-Mar-2004 jkoshy

Cross-reference contigmalloc(9).


# 125889 16-Feb-2004 des

Back out previous commit due to objections.


# 125883 16-Feb-2004 des

Document the change in M_WAITOK semantics.


# 119893 08-Sep-2003 ru

mdoc(7): Use the new feature of the .In macro.


# 116254 12-Jun-2003 harti

Rename the section 'locking considerations' into 'context'.
Change the wording in this section to get rid of references to mutexes
and talk about sleeping instead.

Discussed with: jhb@, ru@


# 115209 21-May-2003 ru

Assorted mdoc(7), grammar, spelling, and punctuation fixes.

Approved by: re (blanket)


# 114781 06-May-2003 hmp

malloc(9) types can be used to identify multiple allocations.

PR: docs/38618
Approved by: des (mentor)


# 113332 10-Apr-2003 harti

Forced commit to fill in the fields below for the last commit. Also
bump the date of the man page.

PR: docs/24797
Reviewed by: bde, jake, jhb


# 113283 09-Apr-2003 harti

Explicitely document the locking requirements for the malloc interface.
While beeing here also correct the following:

- list missing macros in the header
- document MALLOC_DEFINE and MALLOC_DECLARE in the SYNOPSIS section
- document additional include requirements for MALLOC_DEFINE
- M_NOWAIT is not 0 anymore
- remove rotted diagnostic messages


# 111413 24-Feb-2003 trhodes

Return bits which were removed in revision 1.28.

Requested by: imp


# 110397 05-Feb-2003 charnier

The .Fn function


# 109624 21-Jan-2003 alfred

Catch up to WAIT/NOWAIT cleanup.


# 109537 19-Jan-2003 sheldonh

Add required commas that were ommitted in the previous delta; the
SEE ALSO section's list of manual pages must be comma-separated.


# 109493 18-Jan-2003 alfred

Document lock order reversals possible when calling allocation functions
with vnode interlocks held.

Emphasize that users need to be careful with malloc flags versus mbuf
flags.

Remove stale portion in vnode.9 about v_tag. We don't have it anylonger.

Submitted by: Hiten Pandya <hiten@unixdaemons.com>


# 109459 18-Jan-2003 rwatson

Caution programmers not to confuse M_DONTWAIT with M_NOWAIT. They
are not the same.

Suggested by: Hiten Pandya <hiten@unixdaemons.com>


# 108260 24-Dec-2002 ru

Spelling: s/then/than/ where appropriate.


# 92567 18-Mar-2002 ru

mdoc(7) police: fixed some wording, kill whitespace at EOL.


# 92194 12-Mar-2002 archie

Add realloc() and reallocf(), and make free(NULL, ...) acceptable.

Reviewed by: alfred


# 84306 01-Oct-2001 ru

mdoc(7) police: Use the new .In macro for #include statements.


# 82249 23-Aug-2001 jhb

Spelling fix: depreciated -> deprecated.


# 82248 23-Aug-2001 jhb

Remove refernces to M_ASLEEP/asleep/await.


# 79727 14-Jul-2001 schweikh

Removed whitespace at end-of-line; no content changes. I simply did
cd src/share; find man[1-9] -type f|xargs perl -pi -e 's/[ \t]+$//'

BTW, what editors are the culprits? I'm using vim and it shows
me whitespace at EOL in troff files with a thick blue block...

Reviewed by: Silence from cvs diff -b
MFC after: 7 days


# 79538 10-Jul-2001 ru

mdoc(7) police: removed HISTORY info from the .Os call.


# 72123 07-Feb-2001 ru

mdoc(7) police: Removed extraneous .No call. The .Nm macro in
mdocNG has been fixed to properly handle its arguments so this
was causing the extraneous (undesirable) space.


# 70466 29-Dec-2000 ru

Prepare for mdoc(7)NG.


# 67384 20-Oct-2000 phk

Introduce the M_ZERO flag to malloc(9)

Instead of:

foo = malloc(sizeof(foo), M_WAIT);
bzero(foo, sizeof(foo));

You can now (and please do) use:

foo = malloc(sizeof(foo), M_WAIT | M_ZERO);

In the future this will enable us to do idle-time pre-zeroing of
malloc-space.


# 57731 03-Mar-2000 sheldonh

Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.


# 51795 29-Sep-1999 dillon

Bring kernel malloc documentation up to date, including the example.

PR: docs/10059


# 50476 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48795 12-Jul-1999 nik

Add $Id$, to make it simpler for members of the translation teams to
track.

The $Id$ line is normally at the bottom of the main comment block in the
man page, separated from the rest of the manpage by an empty comment,
like so;

.\" $Id$
.\"

If the immediately preceding comment is a @(#) format ID marker than the
the $Id$ will line up underneath it with no intervening blank lines.
Otherwise, an additional blank line is inserted.

Approved by: bde


# 48264 27-Jun-1999 mpp

Fix some typos and do some minor mdoc cleanup.


# 43920 12-Feb-1999 alex

Removed occurrences of consecutive repeated words (such as "the the").


# 42025 22-Dec-1998 dillon

M_AWAIT changed to M_ASLEEP


# 42024 22-Dec-1998 dillon

Documentation update for new M_AWAIT flag to kernel malloc, plus revamp
the descriptions of the flags and return value.


# 37331 02-Jul-1998 phk

Fix argument reversal in example.
PR: 7138
Reviewed by: phk
Submitted by: Robert Watson <robert+freebsd@cyrus.watson.org>


# 33923 28-Feb-1998 jraynard

Fix a few typos.


# 32572 16-Jan-1998 bde

Fixed a missing #include in the synopsis.


# 30296 11-Oct-1997 phk

Update malloc.9 to reflect new reality.


# 24126 22-Mar-1997 mpp

Add malloc(9) to document the kernel malloc() and free() routines.

Obtained from: NetBSD w/changes to reflect current FreeBSD headers
and diagnostic messages.