Index: head/share/security/advisories/FreeBSD-SA-16:37.libc.asc =================================================================== --- head/share/security/advisories/FreeBSD-SA-16:37.libc.asc (revision 49714) +++ head/share/security/advisories/FreeBSD-SA-16:37.libc.asc (revision 49715) @@ -1,139 +1,156 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 ============================================================================= FreeBSD-SA-16:37.libc Security Advisory The FreeBSD Project Topic: link_ntoa(3) buffer overflow Category: core Module: libc -Announced: 2016-12-06 +Announced: 2016-12-06, revised on 2016-12-08 Affects: All supported versions of FreeBSD. -Corrected: 2016-12-06 18:53:21 UTC (stable/11, 11.0-STABLE) - 2016-12-06 18:49:38 UTC (releng/11.0, 11.0-RELEASE-p4) - 2016-12-06 18:53:46 UTC (stable/10, 10.3-STABLE) - 2016-12-06 18:49:48 UTC (releng/10.3, 10.3-RELEASE-p13) - 2016-12-06 18:49:54 UTC (releng/10.2, 10.2-RELEASE-p26) - 2016-12-06 18:49:59 UTC (releng/10.1, 10.1-RELEASE-p43) - 2016-12-06 18:54:04 UTC (stable/9, 9.3-STABLE) - 2016-12-06 18:50:06 UTC (releng/9.3, 9.3-RELEASE-p51) +Corrected: 2016-12-07 23:19:46 UTC (stable/11, 11.0-STABLE) + 2016-12-07 23:29:42 UTC (releng/11.0, 11.0-RELEASE-p5) + 2016-12-07 23:20:26 UTC (stable/10, 10.3-STABLE) + 2016-12-07 23:31:07 UTC (releng/10.3, 10.3-RELEASE-p14) + 2016-12-07 23:32:42 UTC (releng/10.2, 10.2-RELEASE-p27) + 2016-12-07 23:34:06 UTC (releng/10.1, 10.1-RELEASE-p44) + 2016-12-07 23:20:50 UTC (stable/9, 9.3-STABLE) + 2016-12-07 23:35:15 UTC (releng/9.3, 9.3-RELEASE-p52) CVE Name: CVE-2016-6559 For general information regarding FreeBSD Security Advisories, including descriptions of the fields above, security branches, and the following sections, please visit . +0. Revision history. + +v1.0 2016-12-06 Initial release. +v1.1 2016-12-08 Revised patches to address regressions. + I. Background The link_ntoa(3) function generates ASCII representation of a link-level address and is avaliable as part of standard C library (libc). II. Problem Description A specially crafted argument can trigger a static buffer overflow in the library, with possibility to rewrite following static buffers that belong to other library functions. III. Impact Due to very limited use of the function in the existing applications, and limited length of the overflow, exploitation of the vulnerability does not seem feasible. None of the utilities and daemons in the base system are known to be vulnerable. However, careful review of third party software that may use the function was not performed. IV. Workaround No workaround is available. V. Solution Perform one of the following: 1) Upgrade your vulnerable system to a supported FreeBSD stable or release / security branch (releng) dated after the correction date. 2) To update your vulnerable system via a binary patch: Systems running a RELEASE version of FreeBSD on the i386 or amd64 platforms can be updated via the freebsd-update(8) utility: # freebsd-update fetch # freebsd-update install Restart all daemons that use the library, or reboot the system. 3) 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. +[*** v1.1 NOTE ***] If your sources are not yet patched using the initially +published patch, then you need to apply libc.patch. If your sources are +already updated, or patched with patch from the initial advisory, then you +need to apply the incremental patch, named libc-inc.patch. + +[FreeBSD system, not patched with initial SA-16:37 patch] # fetch https://security.FreeBSD.org/patches/SA-16:37/libc.patch # fetch https://security.FreeBSD.org/patches/SA-16:37/libc.patch.asc # gpg --verify libc.patch.asc +[FreeBSD system, initial SA-16:37 patch already applied] +# fetch https://security.FreeBSD.org/patches/SA-16:37/libc-inc.patch +# fetch https://security.FreeBSD.org/patches/SA-16:37/libc-inc.patch.asc +# gpg --verify libc-inc.patch.asc + b) Apply the patch. Execute the following commands as root: # cd /usr/src # patch < /path/to/patch c) Recompile the operating system using buildworld and installworld as described in . Restart all daemons that use the library, or reboot the system. VI. Correction details The following list contains the correction revision numbers for each affected branch. Branch/path Revision - ------------------------------------------------------------------------- -stable/9/ r309646 -releng/9.3/ r309637 -stable/10/ r309645 -releng/10.1/ r309636 -releng/10.2/ r309635 -releng/10.3/ r309634 -stable/11/ r309644 -releng/11.0/ r309633 +stable/9/ r309691 +releng/9.3/ r309697 +stable/10/ r309690 +releng/10.1/ r309696 +releng/10.2/ r309694 +releng/10.3/ r309693 +stable/11/ r309689 +releng/11.0/ r309692 - ------------------------------------------------------------------------- To see which files were modified by a particular revision, run the following command, replacing NNNNNN with the revision number, on a machine with Subversion installed: # svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base Or visit the following URL, replacing NNNNNN with the revision number: VII. References + The latest revision of this advisory is available at -----BEGIN PGP SIGNATURE----- -iQIcBAEBCgAGBQJYRw1vAAoJEO1n7NZdz2rnk5sP/18NuTRoit3jfa1uHCYMyTOB -vOGtNtn5xs8NNY4wAdYx2cF3CscTZEWyQtXWsMWzXgbWI0KrWteacGDaDlFwraCu -9/TJmkCQC5FCfYsgQFOpOPtMl9W+gY2ZrmEPXsfc/smjvIas3fPCBjnoRM2qQlfc -25YIut+S6OFhm2XM42t/jljbLs6b/PJikeKt7kEEEjKKXWHNwLEYjbtEyelKxD1i -1IBVe4Run2RajERg99yCznAGGvRo2hbGmnV59kDAilanJK+s3pzCOBFdnKyZd/2l -Ie8B/fKEXRJyFgJF7A9eSuElTV5fCFfX05AC3PXMoi+GsVPQqhEpNb1FvJoANiFL -l61nbqkM5KEteIWvf1udHZo6kjhYY4YlvutXW7o41XaUhnaO3dC+4+VpfTycH/no -j8kVFS1Y9oun31TTZ/+aQqnCfozAMKFaZtrZI3UkSR1kjz5Z5Rqrc4isBhXXP1dQ -QC87THCyW2D1+E0LvMyJEWKtjGMd8OO5KZjvTxcmxDSrqEOn+yGT1Lp8G/NLuQ4D -zcarPPl2eE0bikvL/T/k7OdpplTDXoaCOHiMIr02WpbJwipw6HD4FZrg1IQu/Db9 -2cHihr/tS1mbr7k/VKUyIZvQQhZ9j72m4wwBk0CFEG8DeZtMeSum1xgLTEjUerHe -rWrKG2feWv//R0BvVNhu -=8y53 +iQIcBAEBCgAGBQJYSNoxAAoJEO1n7NZdz2rnQfQP/0oJ8WdTTVMpjEHRBQ7WbayB +f7Y8MeVFErNLL8caQDxRyiF/ex07m5m2morik84ggDTkHiWnllaP0H3MadivP9Ly +XspViMU73r49PmYTAsrMARyW2ncufgGpsvaEcVOVKEAiwcm0ATu7gnTf+cyrfWoe +k9HlTS18bN18zQ/FFSJPjmIsTh8Cb+cdF6SrVEt7bIcoVzZWMU/sDJP9JDnRFa3+ +o7bWDQg3kfA8k3XEzrL9FSO52Sr9jNslZGAaycFFQjxecgC/05mTbqPsJOpdhkaC +mfcARX/8+iwxsE/3h7R5OK6vsu6piUE6vi8HsnTwK7ZMz/IYkPpe4C9WroRYAG29 +mqBl+qdVElk/DXPgsz6F7PHqG3SUY3Kkn/bMGT4B3yLjNvWs4+pjh74uyvVLPKkQ +meQEs3VLl+c0VkpAxbieMS1KChJwBAKAD7Cevg83YfosC8/LFRoqS6kofjXjVqCd +dd0cSWyOE6y/eFy2187lncnz1BNW1Eg8AEH02vEkXOI5hrnhmO6t0cH9dQcj3nHa +6yULqFHJJJGsGqPD1/FkXjn7hAMKsMMROCGpY0txNVA2a3Z6zf593nZL7Vr1nPy7 +7C7/sKToSilR3OJGoSFxNlRHqkgb08dQOzsof/355M94baKw82QAULuQoOBYu0DU +PZ21bNtGfZSN4rThyVuQ +=Id1+ -----END PGP SIGNATURE----- Index: head/share/security/patches/SA-16:37/libc-inc.patch =================================================================== --- head/share/security/patches/SA-16:37/libc-inc.patch (nonexistent) +++ head/share/security/patches/SA-16:37/libc-inc.patch (revision 49715) @@ -0,0 +1,43 @@ +--- lib/libc/net/linkaddr.c.orig ++++ lib/libc/net/linkaddr.c +@@ -125,7 +125,7 @@ + static char obuf[64]; + _Static_assert(sizeof(obuf) >= IFNAMSIZ + 20, "obuf is too small"); + char *out; +- const char *in, *inlim; ++ const u_char *in, *inlim; + int namelen, i, rem; + + namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ; +@@ -142,11 +142,11 @@ + } + } + +- in = (const char *)sdl->sdl_data + sdl->sdl_nlen; ++ in = (const u_char *)sdl->sdl_data + sdl->sdl_nlen; + inlim = in + sdl->sdl_alen; + + while (in < inlim && rem > 1) { +- if (in != (const char *)sdl->sdl_data + sdl->sdl_nlen) { ++ if (in != (const u_char *)sdl->sdl_data + sdl->sdl_nlen) { + *out++ = '.'; + rem--; + } +@@ -154,15 +154,14 @@ + if (i > 0xf) { + if (rem < 3) + break; ++ *out++ = hexlist[i >> 4]; + *out++ = hexlist[i & 0xf]; +- i >>= 4; +- *out++ = hexlist[i]; + rem -= 2; + } else { + if (rem < 2) + break; + *out++ = hexlist[i]; +- rem++; ++ rem--; + } + } + *out = 0; Property changes on: head/share/security/patches/SA-16:37/libc-inc.patch ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/security/patches/SA-16:37/libc-inc.patch.asc =================================================================== --- head/share/security/patches/SA-16:37/libc-inc.patch.asc (nonexistent) +++ head/share/security/patches/SA-16:37/libc-inc.patch.asc (revision 49715) @@ -0,0 +1,16 @@ +-----BEGIN PGP SIGNATURE----- + +iQIcBAABCgAGBQJYSNpCAAoJEO1n7NZdz2rnQhwQAIB9bWgYA4tn7fHwbpmEZrrz +9clKJ+DUrINrgjD4R5J52b2vTirwSX+jLhwcblDcFz85VeoIc8xDPpd8rvFa9znC +UZ2SBI0itfVZQkEGu+uEJE+9QdEr2jbwq1LIr3Ye3SECQJORlg11detvPEbNyDvm +20DrfR+BPFvDSGKGEbKvegGaPUTv+MYXx3Km4jiXDB/Bo7lUjmE/mdIZszskzJpM +AKx4moCR0Wep73vxGOhi2GArf+p4ZUe9eu0wdU/NTKzYH5DdjGnV+bNam2SdpgDT +rMfrvpUJ+uqdZ1cj7yCsPjuKzskKdWihOCD+vHS3rC00ggYCQv5gnnnyo08z4qRE +e0yU/4lj68i0X1E6gUIvATW7Y4r4EqX5xNl/nKfpgFQSqJRtZGbmlUH/7eni82Fh +W3BKZsUyTtZJIod+SlmEloOlsqpRpL+ePSKXv5e0vLq6pr4tdLFFrPaKsi+6AbFO +mfVSHGJIdB7WUaau34ymhpyb1SI1qrEoNNoYki6SNfuXsghgQKgghwl0cWpJEsUp +Atg+BQH7ea2sPQh9BXqsiSiUb6wuyi/JHeuBQ4pQcKzyf7RuyxaA7rtr2p0w+UBG +MRgceUP4H8XxCCltddq2WrNTB5dmac0t5ehYO8eJpQgtWPsl8yG5PldHkXWkhEa6 +gJVPBsoQJObVrkM/PXrl +=/W0I +-----END PGP SIGNATURE----- Property changes on: head/share/security/patches/SA-16:37/libc-inc.patch.asc ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/security/patches/SA-16:37/libc.patch =================================================================== --- head/share/security/patches/SA-16:37/libc.patch (revision 49714) +++ head/share/security/patches/SA-16:37/libc.patch (revision 49715) @@ -1,75 +1,75 @@ --- lib/libc/net/linkaddr.c.orig +++ lib/libc/net/linkaddr.c @@ -35,6 +35,7 @@ #include #include +#include #include #include -@@ -122,31 +123,47 @@ +@@ -122,31 +123,46 @@ link_ntoa(const struct sockaddr_dl *sdl) { static char obuf[64]; - char *out = obuf; - int i; - u_char *in = (u_char *)LLADDR(sdl); - u_char *inlim = in + sdl->sdl_alen; - int firsttime = 1; + _Static_assert(sizeof(obuf) >= IFNAMSIZ + 20, "obuf is too small"); + char *out; -+ const char *in, *inlim; ++ const u_char *in, *inlim; + int namelen, i, rem; - if (sdl->sdl_nlen) { - bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen); - out += sdl->sdl_nlen; - if (sdl->sdl_alen) + namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ; + + out = obuf; + rem = sizeof(obuf); + if (namelen > 0) { + bcopy(sdl->sdl_data, out, namelen); + out += namelen; + rem -= namelen; + if (sdl->sdl_alen > 0) { *out++ = ':'; + rem--; + } } - while (in < inlim) { - if (firsttime) - firsttime = 0; - else + -+ in = (const char *)sdl->sdl_data + sdl->sdl_nlen; ++ in = (const u_char *)sdl->sdl_data + sdl->sdl_nlen; + inlim = in + sdl->sdl_alen; + + while (in < inlim && rem > 1) { -+ if (in != (const char *)sdl->sdl_data + sdl->sdl_nlen) { ++ if (in != (const u_char *)sdl->sdl_data + sdl->sdl_nlen) { *out++ = '.'; + rem--; + } i = *in++; if (i > 0xf) { - out[1] = hexlist[i & 0xf]; -+ if (rem < 3) -+ break; -+ *out++ = hexlist[i & 0xf]; - i >>= 4; +- i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; ++ if (rem < 3) ++ break; ++ *out++ = hexlist[i >> 4]; ++ *out++ = hexlist[i & 0xf]; + rem -= 2; + } else { + if (rem < 2) + break; -+ *out++ = hexlist[i]; -+ rem++; + *out++ = hexlist[i]; ++ rem--; + } } *out = 0; return (obuf); Index: head/share/security/patches/SA-16:37/libc.patch.asc =================================================================== --- head/share/security/patches/SA-16:37/libc.patch.asc (revision 49714) +++ head/share/security/patches/SA-16:37/libc.patch.asc (revision 49715) @@ -1,16 +1,16 @@ -----BEGIN PGP SIGNATURE----- -iQIcBAABCgAGBQJYRw1vAAoJEO1n7NZdz2rnH2QP/jQF/xtjDHJoEKk3h6DGZUC4 -GM27jneyYt/SWbGVHchYhD6y+67304OeUCZ7N6aEUI3cVgoZObDuVNoNrtfBnSPB -gTtAOUQchlF0ZP/TKZSrONz6Pz+1R/N9QryJSDYr3KUsLDuU6I2nob7kR+Iwxn1V -pX8MakPMSOUH8tHHpXlQySN8rjobtiCdvulDyi0IX92Ajdq7fqLlu2oiHsMYdtfW -hzWahmHJZUFe0CqLc+78vGB5WTsIXcwSfrkq5MVy8hDlbtmFrgyXcReEBnXSw+kC -Y751w+W674Cck/60inzA3is7Iy84/yE0fGuBmFWPhOatTbVqI6dG+gK0CqlzW8g7 -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