Date: Thu, 27 May 2021 10:35:52 -0700 From: Gordon Tetlow <gordon@tetlows.org> To: freebsd-security <freebsd-security@freebsd.org> Subject: Re: FreeBSD Security Advisory FreeBSD-SA-21:11.smap Message-ID: <0FAFDFB3-84AA-4E30-82F5-61236EC0B3F7@tetlows.org> In-Reply-To: <20210527005453.A12B017B88@freefall.freebsd.org> References: <20210527005453.A12B017B88@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_EDF37FD6-82EF-4DF7-A339-136F68EE2A75 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Since I had a question on this in another forum, I figure I'll copy it = to the public list as well. The credit line below was specifically = requested by the reporter. It wasn't a typo or a lack of proof-reading = on our part. Best, Gordon Hat: security-officer > On May 26, 2021, at 5:54 PM, FreeBSD Security Advisories = <security-advisories@freebsd.org> wrote: >=20 > Signed PGP part > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > FreeBSD-SA-21:11.smap Security = Advisory > The FreeBSD = Project >=20 > Topic: SMAP bypass >=20 > Category: core > Module: amd64 > Announced: 2021-05-26 > Credits: I lost my dog if you see him please contact me at = @m00nbsd. > Affects: FreeBSD 12.2 and later. > Corrected: 2021-05-26 19:18:54 UTC (stable/13, 13.0-STABLE) > 2021-05-26 19:31:50 UTC (releng/13.0, 13.0-RELEASE-p1) > 2021-05-26 19:30:31 UTC (stable/12, 12.2-STABLE) > 2021-05-26 20:40:20 UTC (releng/12.2, 12.2-RELEASE-p7) > CVE Name: CVE-2021-29628 >=20 > For general information regarding FreeBSD Security Advisories, > including descriptions of the fields above, security branches, and the > following sections, please visit <URL:https://security.FreeBSD.org/>. >=20 > I. Background >=20 > Supervisor Mode Access Prevention (SMAP) is a security feature > implemented by contemporary Intel and AMD CPUs. When enabled, it > ensures that accesses to user memory by the kernel trigger a page = fault > and a subsequent kernel panic. This helps mitigate the security > implications of kernel bugs that permit an attacker to read from or > write to user memory from the kernel. >=20 > The kernel may legitimately need to copy data between userspace and = the > kernel. To enable this, SMAP is temporarily disabled in the = subroutines > which handle this copying, so only small, specially designated = portions > of the kernel should be executed with SMAP disabled. >=20 > II. Problem Description >=20 > The FreeBSD kernel enables SMAP during boot when the CPU reports that > the SMAP capability is present. Subroutines such as copyin() and > copyout() are responsible for disabling SMAP around the sections of = code > that perform user memory accesses. >=20 > Such subroutines must handle page faults triggered when user memory is > not mapped. The kernel's page fault handler checks the validity of = the > fault, and if it is indeed valid it will map a page and resume = copying. > If the fault is invalid, the fault handler returns control to a > trampoline which aborts the operation and causes an error to be > returned. In this second scenario, a bug in the implementation of = SMAP > support meant that SMAP would remain disabled until the thread returns > to user mode. >=20 > III. Impact >=20 > This bug may be used to bypass the protections provided by SMAP for = the > duration of a system call. It could thus be combined with other = kernel > bugs to craft an exploit. >=20 > IV. Workaround >=20 > No workaround is available. On hardware that does not implement SMAP, > the bug is inconsequential as the mitigation does not exist in the = first > place. >=20 > V. Solution >=20 > Upgrade your vulnerable system to a supported FreeBSD stable or > release / security branch (releng) dated after the correction date > and reboot. >=20 > Perform one of the following: >=20 > 1) To update your vulnerable system via a binary patch: >=20 > 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: >=20 > # freebsd-update fetch > # freebsd-update install > # shutdown -r +10min "Rebooting for a security update" >=20 > 2) To update your vulnerable system via a source code patch: >=20 > The following patches have been verified to apply to the applicable > FreeBSD release branches. >=20 > a) Download the relevant patch from the location below, and verify the > detached PGP signature using your PGP utility. >=20 > # fetch https://security.FreeBSD.org/patches/SA-21:11/smap.patch > # fetch https://security.FreeBSD.org/patches/SA-21:11/smap.patch.asc > # gpg --verify smap.patch.asc >=20 > b) Apply the patch. Execute the following commands as root: >=20 > # cd /usr/src > # patch < /path/to/patch >=20 > c) Recompile your kernel as described in > <URL:https://www.FreeBSD.org/handbook/kernelconfig.html> and reboot = the > system. >=20 > VI. Correction details >=20 > This issue is corrected by the corresponding Git commit hash or = Subversion > revision number in the following stable and release branches: >=20 > Branch/path Hash = Revision > = ------------------------------------------------------------------------- > stable/13/ 876ffe28796c = stable/13-n245764 > releng/13.0/ f32130a1955e = releng/13.0-n244739 > stable/12/ = r369857 > releng/12.2/ = r369863 > = ------------------------------------------------------------------------- >=20 > For FreeBSD 13 and later: >=20 > Run the following command to see which files were modified by a > particular commit: >=20 > # git show --stat <commit hash> >=20 > Or visit the following URL, replacing NNNNNN with the hash: >=20 > <URL:https://cgit.freebsd.org/src/commit/?id=3DNNNNNN> >=20 > To determine the commit count in a working tree (for comparison = against > nNNNNNN in the table above), run: >=20 > # git rev-list --count --first-parent HEAD >=20 > For FreeBSD 12 and earlier: >=20 > Run the following command to see which files were modified by a = particular > revision, replacing NNNNNN with the revision number: >=20 > # svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base >=20 > Or visit the following URL, replacing NNNNNN with the revision number: >=20 > <URL:https://svnweb.freebsd.org/base?view=3Drevision&revision=3DNNNNNN> >=20 > VII. References >=20 > <URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=3DCVE-2021-29628> >=20 > The latest revision of this advisory is available at > = <URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-21:11.smap.asc> >=20 >=20 --Apple-Mail=_EDF37FD6-82EF-4DF7-A339-136F68EE2A75 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEuyjUCzYO7pNq7RVv5fe8y6O93fgFAmCv2HgACgkQ5fe8y6O9 3fjdowf+LJxpbSt2x2VHTltKQubULy8IReWQCggJh5sfr1BwvbyXgdJTx0OGWjDc xzXvtUzzwL7Q1LVj/rFpMpLTSITakPZq25wgkWZaL3P3k/Wksox8/1dT87yCJ4sG uEE3Ta1PvE08EHhQdPL0qRd1IcJXj9sBAnaH0W33Ngy5wMsY71s8dIdrezT2ouMK IUNgu+r76RW8uPa9eKP6gm2CPGLhz22TN04Lu5Vsf+t4NvHzE7XgRs0wUqFV4XDB n3uAMWNv57yUAZLRQB794rI4GwjCcbCHEej1xJIACNz1LD/cs2qz0HS1Rp1BOJz5 H7Y8qOpwDxwPnt0snSjTQQqAAf/Ebg== =FaTD -----END PGP SIGNATURE----- --Apple-Mail=_EDF37FD6-82EF-4DF7-A339-136F68EE2A75--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0FAFDFB3-84AA-4E30-82F5-61236EC0B3F7>