From nobody Fri Apr 26 11:34:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547195479393466.46174314173777; Fri, 11 Jan 2019 00:31:19 -0800 (PST) Received: from localhost ([127.0.0.1]:55820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghsDi-0003Wd-4v for importer@patchew.org; Fri, 11 Jan 2019 03:31:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghsCc-00031i-5h for qemu-devel@nongnu.org; Fri, 11 Jan 2019 03:30:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghsCa-0008Gr-8n for qemu-devel@nongnu.org; Fri, 11 Jan 2019 03:30:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghsCY-0008CW-56 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 03:30:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC1FA7D0E0; Fri, 11 Jan 2019 08:21:14 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-128.sin2.redhat.com [10.67.116.128]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B959660BE7; Fri, 11 Jan 2019 08:21:12 +0000 (UTC) From: P J P To: QEMU Developers Date: Fri, 11 Jan 2019 13:49:09 +0530 Message-Id: <20190111081909.11896-1-ppandit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 11 Jan 2019 08:21:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] slirp: check data length while emulating ident function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Jason Wang , Kira <864786842@qq.com>, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit While emulating identification protocol, tcp_emu() does not check available space in the 'sc_rcv->sb_data' buffer. It could lead to heap buffer overflow issue. Add check to avoid it. Reported-by: Kira <864786842@qq.com> Signed-off-by: Prasad J Pandit --- slirp/tcp_subr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index fa61349cbb..4415801fbb 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -635,6 +635,11 @@ tcp_emu(struct socket *so, struct mbuf *m) socklen_t addrlen =3D sizeof(struct sockaddr_in); struct sbuf *so_rcv =3D &so->so_rcv; =20 + if (m->m_len > so_rcv->sb_datalen + - (so_rcv->sb_wptr - so_rcv->sb_data)) { + m_free(m); + return 0; + } memcpy(so_rcv->sb_wptr, m->m_data, m->m_len); so_rcv->sb_wptr +=3D m->m_len; so_rcv->sb_rptr +=3D m->m_len; --=20 2.20.1