CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix" (bug 22542)

Processing an overlong pathname in the sunrpc clnt_create function
results in a stack-based buffer overflow.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 226b46770c)
This commit is contained in:
Florian Weimer 2022-01-17 10:21:34 +01:00 committed by Aurelien Jarno
parent 547b63bf6d
commit c4c833d3dd
2 changed files with 12 additions and 3 deletions

5
NEWS
View File

@ -12,6 +12,7 @@ The following bugs are resolved with this release:
(CVE-2016-10228) (CVE-2016-10228)
[20019] NULL pointer dereference in libc.so.6 IFUNC due to uninitialized GOT [20019] NULL pointer dereference in libc.so.6 IFUNC due to uninitialized GOT
[20543] Please move from .gnu.linkonce to comdat [20543] Please move from .gnu.linkonce to comdat
[22542] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix"
[23296] Data race in setting function descriptor during lazy binding [23296] Data race in setting function descriptor during lazy binding
[24973] iconv encounters segmentation fault when converting 0x00 0xfe in [24973] iconv encounters segmentation fault when converting 0x00 0xfe in
EUC-KR to UTF-8 (CVE-2019-25013) EUC-KR to UTF-8 (CVE-2019-25013)
@ -67,6 +68,10 @@ Security related changes:
CVE-2020-29562: An assertion failure has been fixed in the iconv function CVE-2020-29562: An assertion failure has been fixed in the iconv function
when invoked with UCS4 input containing an invalid character. when invoked with UCS4 input containing an invalid character.
CVE-2022-23219: Passing an overlong file name to the clnt_create
legacy function could result in a stack-based buffer overflow when
using the "unix" protocol. Reported by Martin Sebor.
Version 2.31 Version 2.31

View File

@ -57,9 +57,13 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
if (strcmp (proto, "unix") == 0) if (strcmp (proto, "unix") == 0)
{ {
memset ((char *)&sun, 0, sizeof (sun)); if (__sockaddr_un_set (&sun, hostname) < 0)
sun.sun_family = AF_UNIX; {
strcpy (sun.sun_path, hostname); struct rpc_createerr *ce = &get_rpc_createerr ();
ce->cf_stat = RPC_SYSTEMERROR;
ce->cf_error.re_errno = errno;
return NULL;
}
sock = RPC_ANYSOCK; sock = RPC_ANYSOCK;
client = clntunix_create (&sun, prog, vers, &sock, 0, 0); client = clntunix_create (&sun, prog, vers, &sock, 0, 0);
if (client == NULL) if (client == NULL)