From nobody Sat May 4 21:31:34 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 1547402595899222.54665693487004; Sun, 13 Jan 2019 10:03:15 -0800 (PST) Received: from localhost ([127.0.0.1]:50471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gik6M-0007rK-4M for importer@patchew.org; Sun, 13 Jan 2019 13:03:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gik5F-0007VL-12 for qemu-devel@nongnu.org; Sun, 13 Jan 2019 13:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gik5D-0004ln-RX for qemu-devel@nongnu.org; Sun, 13 Jan 2019 13:02:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gik5D-0004h6-LU for qemu-devel@nongnu.org; Sun, 13 Jan 2019 13:02:03 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBD3387628; Sun, 13 Jan 2019 18:01:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A495C600C8; Sun, 13 Jan 2019 18:01:51 +0000 (UTC) From: P J P To: QEMU Developers Date: Sun, 13 Jan 2019 23:29:48 +0530 Message-Id: <20190113175948.21076-1-ppandit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 13 Jan 2019 18:01:55 +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 v2] 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: Prasad J Pandit , Jan Kiszka , Jason Wang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Samuel Thibault , Kira <864786842@qq.com> 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 | 4 ++++ 1 file changed, 4 insertions(+) Update v2: return 1 instead of 0 -> https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg02182.html diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index fa61349cbb..8b1bd8c8c0 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -635,6 +635,10 @@ 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)) { + return 1; + } 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