From patchwork Wed Jan 12 17:01:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 49928 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F56A393A431 for ; Wed, 12 Jan 2022 17:02:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F56A393A431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1642006962; bh=ac0UpnTRVbncRp3xesTIc6cqAxR4kpgMVjU2uInRQXs=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UxSoMeXUmq0bumGMHAP+BLvI4XJDH8estvRgVDei2sUqQAYRoKvxfb88tO5ZWLTSl a5AHo/n5b6x3wL6NwWAPS4BKKxzaui/QQNPCdJP/v+iljln1g2NCJAeYZiQ462Stjx Mn94cIRW+dLf4sEvwfMUEjrLWgJEgK/UJHVQyQ9k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DB02E389ACA3 for ; Wed, 12 Jan 2022 17:01:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB02E389ACA3 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-nr6dRFEVNimVICEg2PSXCw-1; Wed, 12 Jan 2022 12:01:06 -0500 X-MC-Unique: nr6dRFEVNimVICEg2PSXCw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9037F760C0 for ; Wed, 12 Jan 2022 17:01:05 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9BF82E058; Wed, 12 Jan 2022 17:01:04 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 2/4] sunrpc: Fix buffer overflow in clnt_create for "unix" (bug 22542) In-Reply-To: References: X-From-Line: 45c34dc5c219694082d000a7e2975183469e3196 Mon Sep 17 00:00:00 2001 Message-Id: <45c34dc5c219694082d000a7e2975183469e3196.1642006428.git.fweimer@redhat.com> Date: Wed, 12 Jan 2022 18:01:03 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Martin Sebor Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- NEWS | 4 +++- sunrpc/clnt_gen.c | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index a957b19fdc..c1df8e1a0f 100644 --- a/NEWS +++ b/NEWS @@ -150,7 +150,9 @@ Changes to build and runtime requirements: Security related changes: - [Add security related changes here] + 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)