From patchwork Tue Jan 30 18:40:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 85045 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 EB0323857432 for ; Tue, 30 Jan 2024 18:42:10 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 049763857714 for ; Tue, 30 Jan 2024 18:40:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 049763857714 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 049763857714 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706640060; cv=none; b=AK9TwGfQGII9QduuCfkiUNXjjXrDLwpuXTgvbE3y5YB3pWHCqYLxPttxjAgQZZwrAxerH5nVtEkhdOsMKgMrrlc/brgzeFswR8NcJ1qSGRxM5VSyHoiDFuQ1YnmTa9a1/2MDge6CbXA+KoxHlH+ICWpti9bYzOuqx3bjTp01LXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706640060; c=relaxed/simple; bh=nZ+hcJjjxTmJowltMN8Z4HhiFSfk1e9FtGM6ugD//4I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=noQJ8dW1jF0ckNwvm6k6pjrlnBFtKFI91/YotoO+83xoBfZdBiq+k0bA+wxeXPOa9GOViSVTWpK4RXf/a02a87Ewjp0o1wM/Y1mPBzhMkbOxachqbuiu0hxfq2ykbFs4xRQ1VVKL5Vrt1kteTuptN2VuDlTUi38aQtCBWB3/yxw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706640058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QpQi/WFnmc1kJ9FXxs3URkAsu9rcl5ajpSiMl0EKBp8=; b=KSFC7clqO/+VTRZ98evRMmP7bWELqOaZopayoyg9uV6hpegqhg+ATp4NmG3oUum/E0aplR cSkNfgF9QLnZj6y2JcGRrtNKh6Hcsq+8NNGGvIOj0sEv0BzgE4zWIOSiTld1dBfk/y4tMm 6dGkm0JQ87nLS0V6jjDfLmNBHpn3aGI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-481-pu7PLqksOpOK9zKOkR-IkA-1; Tue, 30 Jan 2024 13:40:56 -0500 X-MC-Unique: pu7PLqksOpOK9zKOkR-IkA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3784C1C0512C for ; Tue, 30 Jan 2024 18:40:56 +0000 (UTC) Received: from x1carbon9g.. (dhcp129-93.brq.redhat.com [10.34.129.93]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95BF02026D66; Tue, 30 Jan 2024 18:40:55 +0000 (UTC) From: Arjun Shankar To: libc-alpha@sourceware.org Cc: Arjun Shankar , Carlos O'Donell Subject: [COMMITTED 3/4] syslog: Fix integer overflow in __vsyslog_internal (CVE-2023-6780) Date: Tue, 30 Jan 2024 19:40:43 +0100 Message-ID: <20240130184045.511720-3-arjun@redhat.com> In-Reply-To: <20240130184045.511720-1-arjun@redhat.com> References: <20240130184045.511720-1-arjun@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org __vsyslog_internal calculated a buffer size by adding two integers, but did not first check if the addition would overflow. This commit fixes that. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- misc/syslog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misc/syslog.c b/misc/syslog.c index 53440e47ad..4af87f54fd 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94"; #include #include #include +#include static int LogType = SOCK_DGRAM; /* type of socket connection */ static int LogFile = -1; /* fd for log */ @@ -219,7 +220,7 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, vl = __vsnprintf_internal (pos, len, fmt, apc, mode_flags); va_end (apc); - if (vl < 0) + if (vl < 0 || vl >= INT_MAX - l) goto out; if (vl >= len)