From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from donkey.elm.relay.mailchannels.net (donkey.elm.relay.mailchannels.net [23.83.212.49]) by sourceware.org (Postfix) with ESMTPS id AC7583858402 for ; Mon, 17 Jan 2022 03:29:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AC7583858402 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1C3EA12122D; Mon, 17 Jan 2022 03:29:32 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 85A8F1211D6; Mon, 17 Jan 2022 03:29:31 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.255.161 (trex/6.4.3); Mon, 17 Jan 2022 03:29:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Trade-Soft: 19948389345683f4_1642390171918_435067014 X-MC-Loop-Signature: 1642390171918:3209772107 X-MC-Ingress-Time: 1642390171918 Received: from [192.168.1.174] (unknown [1.186.224.209]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a306.dreamhost.com (Postfix) with ESMTPSA id 4JccpL1hp4z32; Sun, 16 Jan 2022 19:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1642390171; bh=x/QG/s7yNfrgofUNEfzylXkXJZM=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=jKVfO5mi35gNAXuj6rl7uFUCphgZ7jOLyI0FFuQkFWeW+CheJA2Pruqe2L3FWQ108 NkVQUoQr0otAkCEt0Oamcn+6Lob0CFBpbsO4VsdRJb2h0AOsF4earrF7AOoMHji+3g +gK+772Z/w8u/1Z2nHaVqoF2Dn7awyfQwgUN09dw= Message-ID: <1fc61d4b-4efa-4776-b3dc-58741bee3baf@gotplt.org> Date: Mon, 17 Jan 2022 08:59:25 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v2 2/4] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix" (bug 22542) Content-Language: en-US To: Florian Weimer , libc-alpha@sourceware.org References: From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3036.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2022 03:29:35 -0000 On 14/01/2022 13:54, Florian Weimer via Libc-alpha wrote: > Processing an overlong pathname in the sunrpc clnt_create function > results in a stack-based buffer overflow. > --- > NEWS | 4 +++- > sunrpc/clnt_gen.c | 10 +++++++--- > 2 files changed, 10 insertions(+), 4 deletions(-) LGTM. Reviewed-by: Siddhesh Poyarekar > > diff --git a/NEWS b/NEWS > index a957b19fdc..94248b580d 100644 > --- a/NEWS > +++ b/NEWS > @@ -150,7 +150,9 @@ Changes to build and runtime requirements: > > Security related changes: > > - [Add security related changes here] > + 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: > > 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)