From nobody Fri Nov 14 13:38:16 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1587683939; cv=none; d=zohomail.com; s=zohoarc; b=SlUs4ZBrfXXD5DIIApynVMWoBadezGcgAvfkCPMZn/zIssmzKfd+ui3u6dPW64CVmY2s0I4bbdbj3cVDXB457pX8P64teDnGETGzrqzMXe+QuLPrNdO/BNp3MkiwooGo9pWsHyqmDeVo01wmdyXWvB3on46tftH1XLqQUQhXw9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587683939; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nJURS/g1DqzAgiA/8oS3taBQkSYAAOGZ2MWBgoul9C4=; b=G+FQAb7m98rua3TWcXLJBkVSwTyJmj64B7tctziGQQfYEbyv4kjpGFZ5jU6LK3AWrMiZdOfT37FL4HC9zeq5MHoHBC1oS6FYxlS+adZ3xPAeQONui4AdBVBULbL81zDCYq0ExHByfMb2YqKpZ4rPgwsiQIQ6bhl3oMs7gB3RGAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158768393971139.2605977481129; Thu, 23 Apr 2020 16:18:59 -0700 (PDT) Received: from localhost ([::1]:44758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRl7Q-0000fk-Aj for importer@patchew.org; Thu, 23 Apr 2020 19:18:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51738) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRl5a-0007Lw-24 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:17:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRl5R-0006oc-Oy for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:17:01 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRl5R-0006k4-AB for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:53 -0400 Received: by mail-wr1-x441.google.com with SMTP id t14so8585144wrw.12 for ; Thu, 23 Apr 2020 16:16:52 -0700 (PDT) Received: from localhost.localdomain (116.red-83-42-57.dynamicip.rima-tde.net. [83.42.57.116]) by smtp.gmail.com with ESMTPSA id h13sm5498122wrs.22.2020.04.23.16.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 16:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nJURS/g1DqzAgiA/8oS3taBQkSYAAOGZ2MWBgoul9C4=; b=HavzfZwtrvOxsiQiIKp4GGBmWBHRj4u4ONCHJa0n865BrZT7TACoI2o5TIqNWeIPkg TgurKONOnpmA9Z3bRs42BaT34+HFktTaNsfcVbLPjm4c66M0sBMjepBVYSV0R6NrtTXr CQHIzgiCJ40l3LFxhjm02qbE5dMJwDIGYqgUq7PEvqeJCa0rOZP89h2GGk18NHCmQ0n9 D2TdThbz/ZOI4xaaIfz2MB05vutg5Bmy/QSgJbiy/Cwatn0WURlUp7uHlSEU1dfJ9MzP 6c3I40vxo40CE5Ksixu/uLh5rtOx0XdHqEEkMDlK6JUgRCJXrR813a7Dwp0yPlBHSNmx DnYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nJURS/g1DqzAgiA/8oS3taBQkSYAAOGZ2MWBgoul9C4=; b=j7o9atT7ttHfSNyNCeMo5vtzPgbAcFQJYhPfJ9hFZ714OoXAYMX/Lptixbtoi3e9Bw KIxPNk/+2O8ZFGcctWGDtZrFE8oAv15VRLGapHB3BzTYFI55QBUO7nZTk+Yzc8eX5Vat RyFmLphlLXPtpGsiRCMwCmW3rOKUHCtowix3Vq6DpUcoJCcRjuWJoFBd3QvxvH1YXj09 ry/5tsLckvaF2lw5IZgl/KyekoNW4S9TjPaGxDXl7idk1dFvbCKeXCFQpPW2YTTnOFUu ir7FOYeE68YnvpRY0OI6ykRFv9pbIrx6gdYAx+M8wmvXBjzDChQuQ1kL3qcpKtMmoQ+0 IehA== X-Gm-Message-State: AGi0PuYcFRX1NHrcbENp8tUUqBBwEL7YKpDUVqnLc7fYQ8cBSpuXdmDm 4o0WEvUu1lUaVsYdxqXn2UK6fM0O X-Google-Smtp-Source: APiQypL6CHsOcrS51tjmy5zGENCtOIvxZsFOy2plhOOAY0gptV0JyNNYUMsXZWrrT5SZlPyURk7Pag== X-Received: by 2002:a5d:60ca:: with SMTP id x10mr7383788wrt.407.1587683811658; Thu, 23 Apr 2020 16:16:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 3/3] hw/net/tulip: Set descriptor error bit when lenght is incorrect Date: Fri, 24 Apr 2020 01:16:44 +0200 Message-Id: <20200423231644.15786-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200423231644.15786-1-f4bug@amsat.org> References: <20200423231644.15786-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit , Helge Deller , Li Qiang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li Qiang , Sven Schnelle , Jason Wang , Ziming Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) When a frame lenght is incorrect, set the RDES0 'Error Summary' and 'Frame too long' bits. Then stop the receive process and trigger an abnormal interrupt. See [4.3.5 Receive Process]. Cc: Li Qiang Cc: Li Qiang Cc: Ziming Zhang Cc: Jason Wang Cc: Prasad J Pandit Fixes: 8ffb7265af ("check frame size and r/w data length") Buglink: https://bugs.launchpad.net/bugs/1874539 Reported-by: Helge Deller Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/tulip.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/net/tulip.c b/hw/net/tulip.c index 470f635acb..671f79b6f4 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -158,7 +158,7 @@ static void tulip_next_rx_descriptor(TULIPState *s, s->current_rx_desc &=3D ~3ULL; } =20 -static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *de= sc) +static int tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *des= c) { int len1 =3D (desc->control >> RDES1_BUF1_SIZE_SHIFT) & RDES1_BUF1_SIZ= E_MASK; int len2 =3D (desc->control >> RDES1_BUF2_SIZE_SHIFT) & RDES1_BUF2_SIZ= E_MASK; @@ -177,7 +177,8 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct t= ulip_descriptor *desc) "(ofs: %u, len:%d, size:%zu)\n", __func__, s->rx_frame_len, len, sizeof(s->rx_frame)); - return; + s->rx_frame_len =3D 0; + return -1; } pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame + (s->rx_frame_size - s->rx_frame_len), len); @@ -197,12 +198,15 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct= tulip_descriptor *desc) "(ofs: %u, len:%d, size:%zu)\n", __func__, s->rx_frame_len, len, sizeof(s->rx_frame)); - return; + s->rx_frame_len =3D 0; + return -1; } pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame + (s->rx_frame_size - s->rx_frame_len), len); s->rx_frame_len -=3D len; } + + return 0; } =20 static bool tulip_filter_address(TULIPState *s, const uint8_t *addr) @@ -274,7 +278,11 @@ static ssize_t tulip_receive(TULIPState *s, const uint= 8_t *buf, size_t size) s->rx_frame_len =3D s->rx_frame_size; } =20 - tulip_copy_rx_bytes(s, &desc); + if (tulip_copy_rx_bytes(s, &desc)) { + desc.status |=3D RDES0_ES | RDES0_TL; /* Error: frame too long= */ + s->csr[5] |=3D CSR5_RPS; /* Receive process stopped */ + tulip_update_int(s); + } =20 if (!s->rx_frame_len) { desc.status |=3D s->rx_status; --=20 2.21.1