From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1804) id 4BF8B382F992; Fri, 7 Oct 2022 08:20:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BF8B382F992 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665130843; bh=hSVhskFB3T4U5jmCgODw6uLV+2KU+LRYeCdRHhCvcyk=; h=From:To:Subject:Date:From; b=CykYRCDuU+6VRwoXjvVrF758B2YkHAlw9IQmQ7+XqCqcpZ2Du1Lh+uol1TtStziB6 FhO2F5Bs7A1HuNn9+YEzmsbIfEgtgLe/NqER5FzsVRtkCpLc4esFQmSlAe68sq3Ob5 2LHZRHA963/HCX96yQv7BNnYOEy2ZzERTvl+dLyQ= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Dmitry Levin To: glibc-cvs@sourceware.org Subject: [glibc/release/2.32/master] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix" (bug 22542) X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/release/2.32/master X-Git-Oldrev: b10d5e62a6ac7688305772eb64aac3eda87b1623 X-Git-Newrev: 52d57fc76d7df2a39236a782399fb3efff87895d Message-Id: <20221007082043.4BF8B382F992@sourceware.org> Date: Fri, 7 Oct 2022 08:20:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=52d57fc76d7df2a39236a782399fb3efff87895d commit 52d57fc76d7df2a39236a782399fb3efff87895d Author: Florian Weimer Date: Mon Jan 17 10:21:34 2022 +0100 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 (cherry picked from commit 226b46770c82899b555986583294b049c6ec9b40) Diff: --- NEWS | 5 +++++ sunrpc/clnt_gen.c | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index f087aff61e..53ca17db43 100644 --- a/NEWS +++ b/NEWS @@ -38,9 +38,14 @@ Security related changes: parameter number when processing the expansion resulting in a crash. Reported by Philippe Antoine. + 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. + The following bugs are resolved with this release: [20019] NULL pointer dereference in libc.so.6 IFUNC due to uninitialized GOT + [22542] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix" [24973] locale: iconv encounters segmentation fault when converting 0x00 0xfe in EUC-KR to UTF-8 (CVE-2019-25013) [25399] string: undefined reference to `__warn_memset_zero_len' when diff --git a/sunrpc/clnt_gen.c b/sunrpc/clnt_gen.c index 13ced8994e..b44357cd88 100644 --- a/sunrpc/clnt_gen.c +++ b/sunrpc/clnt_gen.c @@ -57,9 +57,13 @@ clnt_create (const char *hostname, u_long prog, u_long vers, if (strcmp (proto, "unix") == 0) { - memset ((char *)&sun, 0, sizeof (sun)); - sun.sun_family = AF_UNIX; - strcpy (sun.sun_path, hostname); + if (__sockaddr_un_set (&sun, hostname) < 0) + { + struct rpc_createerr *ce = &get_rpc_createerr (); + ce->cf_stat = RPC_SYSTEMERROR; + ce->cf_error.re_errno = errno; + return NULL; + } sock = RPC_ANYSOCK; client = clntunix_create (&sun, prog, vers, &sock, 0, 0); if (client == NULL)