deadsimple BSD Security Advisories and Announcements

FreeBSD Security Advisory FreeBSD-SA-21:09.accept_filter

Hash: SHA512

FreeBSD-SA-21:09.accept_filter                              Security Advisory
                                                          The FreeBSD Project

Topic:          double free in accept_filter(9) socket configuration interface

Category:       core
Module:         accept_filter
Announced:      2021-04-06
Credits:	Alexey Kulaev
Affects:        FreeBSD 12.2 and later.
Corrected:      2021-03-28 00:24:15 UTC (stable/13, 13.0-STABLE)
                2021-03-28 15:03:37 UTC (releng/13.0, 13.0-RC4)
                2021-03-28 00:26:49 UTC (stable/12, 12.2-STABLE)
                2021-04-06 19:21:21 UTC (releng/12.2, 12.2-RELEASE-p6)
CVE Name:       CVE-2021-29627

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:>.

I.   Background

FreeBSD features an accept_filter(9) mechanism which allows an
application to request that the kernel pre-process incoming connections.
For example, the accf_http(9) accept filter prevents accept(2) from
returning until a full HTTP request has been buffered.

No accept filters are enabled by default.  A system administrator must
either compile the FreeBSD kernel with a particular accept filter option
(such as ACCEPT_FILTER_HTTP) or load the filter using kldload(8) in
order to utilize accept filters.

II.  Problem Description

An unprivileged process can configure an accept filter on a listening
socket.  This is done using the setsockopt(2) system call.  The process
supplies the name of the accept filter which is to be attached to the
socket, as well as a string containing filter-specific information.

If the filter implements the accf_create callback, the socket option
handler attempts to preserve the process-supplied argument string.  A
bug in the socket option handler caused this string to be freed
prematurely, leaving a dangling pointer.  Additional operations on the
socket can turn this into a double free or a use-after-free.

III. Impact

The bug may be exploited to trigger local privilege escalation or kernel
memory disclosure.

IV.  Workaround

Systems not using accept filters, or using only the accept filters
included with the FreeBSD base system (accf_data(9), accf_dns(9), and
accf_http(9)) are unaffected.  Note that no accept filters are loaded
in the kernel by default.

Systems using a third-party accept filter module are affected if the
module defines an accf_create callback.  In this case, the only
workaround is to ensure that the module is not loaded into the kernel.

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date
and reboot.

Perform one of the following:

1) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install
# shutdown -r +10min "Rebooting for a security update"

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch
# fetch
# gpg --verify accept_filter.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile your kernel as described in
<URL:> and reboot the

VI.  Correction details

The following list contains the correction revision numbers for each
affected branch.

Branch/path                      Hash                            Revision
- -------------------------------------------------------------------------
stable/13/                       c7d10e7ec872           stable/13-n245050
releng/13.0/                     af6611e5adc6         releng/13.0-n244711
stable/12/                                                        r369525
releng/12.2/                                                      r369553
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing HHHHHH with the hash:


To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://

Or visit the following URL, replacing NNNNNN with the revision number:


VII. References

<other info on vulnerability>


The latest revision of this advisory is available at

_______________________________________________ mailing list
To unsubscribe, send any mail to ""