From nobody Fri Nov 14 12:16:41 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=1587683928; cv=none; d=zohomail.com; s=zohoarc; b=V7Dqexbq5ukiq2o1969rU+1G0k3BGhMYk4ZalMfP16nbZmMleOnIj+lfefEpqPcTTTSsJLQ84ekP9QfcTVpH2mj98LrNd3y6DgaLidtRTXbAhwO/Octvxm1kKL6f9XKNffui/7lKDtN3sO/mbIp0V+/beDf7ANorRnCz27L6DVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587683928; 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=Zzy57pNEhs2f791KQEcET9NOuU+baFBolmqcxp5hb4k=; b=Ij/6GG4QsPAJxJMmkIx1IJ1PV9ZFZ+v+OpU03TCkc0qwtXUduoLr+EVxdGDh5o8gP42xu7N1ZdHVCg6mF0Xq/rctu5xozHAg+baq9gjJwKpZrFCHNEu8s0P6rUD1N0oevUcuknhiCRV1ynTTAyRHqPopPPvh0OEmWjPfr/bO1Is= 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 1587683928540404.9703398320022; Thu, 23 Apr 2020 16:18:48 -0700 (PDT) Received: from localhost ([::1]:44738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRl7G-0000Hc-Ah for importer@patchew.org; Thu, 23 Apr 2020 19:18:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51406) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRl5V-0007EL-0g for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRl5R-0006m9-0n for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:56 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRl5Q-0006iY-Em for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:52 -0400 Received: by mail-wm1-x342.google.com with SMTP id u127so8649371wmg.1 for ; Thu, 23 Apr 2020 16:16:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 16:16:48 -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=Zzy57pNEhs2f791KQEcET9NOuU+baFBolmqcxp5hb4k=; b=KRjyv3Flp2igbZSFmZiPHBeSM9+NjI0IJFxBnHnVhzkhlcqyMYXUiqaAt1GU1Lu8Iv 13wtjVOIqrLxi05OwHTlPXubU2zB1xYRoiH2IXUtIivHXNPAkGi21qasrcbZv4ACS0Ro kEHQu3N/XrhEo+5fmnXrU7VccYECtUsQOLQaoKAlcslrx2R1SWLNaxADR3v+tmUeYVxP 2TuXpCW5ySY84ZDinSsU4D74MM09ZRKwAvm5JQ0hBhz3BFOGBSdo210z2gPI6DKKUcCR +YFXKHS50qM1W79y/zBKjdwSigsTmE8tWonvHXHVc129936Uc9aFtQ+78JeG5I05dfiI 3Lkg== 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=Zzy57pNEhs2f791KQEcET9NOuU+baFBolmqcxp5hb4k=; b=Ng2PUFiYsAqxuUeEsExeP4VjMVMOQ9jkCA7la37kOSwGX5e0ovzz8nPA4fuo92sb2b IpG6KnHH7OkugZdHqA2GC6zpP4SoU26M/U7ZTBKq73CYy/8iL216Ta2qm0z6Zzbi46kn 4T4irX6Q2gJgWTqC4BbvwAvWyK1xAUu5Z7ZjbcGS7lh9UCW3+/9kGYNUDOQRgN1054lB obeXZJ3uObcw2XzhTq/lnZw51VTxTLfPXLx8VOZpe/fOKELNhPj0K2/bbNKojdvG90VD dPgxVXZOAvjMfJOi+ZZ4oCFGw01UsbOVLINvVucOq157zn2rtlKFjaqZZVolrvu66NgA 47JQ== X-Gm-Message-State: AGi0Puanqp27oj+NTsecVsk3yr89RSJ+zdd4wzxKYVJaFb8QcVDz167W Bh5okcocDFtANlbY8EZh+CVDC5/L X-Google-Smtp-Source: APiQypKNLaXSB8e5qYj2hk2DCTpxJNPC9nfi+qUSHaCMWnOGZTCnysYwtvi1lEr8G6pI/qGYLAGm8g== X-Received: by 2002:a05:600c:2214:: with SMTP id z20mr7172214wml.189.1587683808667; Thu, 23 Apr 2020 16:16:48 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 1/3] hw/net/tulip: Fix 'Descriptor Error' definition Date: Fri, 24 Apr 2020 01:16:42 +0200 Message-Id: <20200423231644.15786-2-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::342; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x342.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::342 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: Helge Deller , Sven Schnelle , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Bit #14 is "DE" for 'Descriptor Error': When set, indicates a frame truncation caused by a frame that does not fit within the current descriptor buffers, and that the 21143 does not own the next descriptor. [Table 4-1. RDES0 Bit Fields Description] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/tulip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/tulip.h b/hw/net/tulip.h index 97521b21db..5271aad8d5 100644 --- a/hw/net/tulip.h +++ b/hw/net/tulip.h @@ -211,7 +211,7 @@ #define RDES0_RF BIT(11) #define RDES0_DT_SHIFT 12 #define RDES0_DT_MASK 3 -#define RDES0_LE BIT(14) +#define RDES0_DE BIT(14) #define RDES0_ES BIT(15) #define RDES0_FL_SHIFT 16 #define RDES0_FL_MASK 0x3fff --=20 2.21.1 From nobody Fri Nov 14 12:16:41 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; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1587683932; cv=none; d=zohomail.com; s=zohoarc; b=FcdIRUlCilv6UV9aye8RvVTcUg1w7KMkYKNzNqDx8rc3IcmX9jxy2t0uXIpVscimSfCWxAgvAeTfC52F3wPNx5B2k5Btr2XMAf2BVRAdR9NeBCUYTkhR8EZSRhSKAhTim9JQelqNpaL4jrl65RxZu4MI6LBQpQcmrIp4alj6iKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587683932; 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=mDfF+nCaDRfOLKLYCWQdtmluZlHSpxwXCWsiYI5lMHI=; b=TMYYy83L82VK/qpyH5RdYHAZe+uux0LcCOSsrdcQs50gofU5eeH8m3dF1uOsm8TyXd0cVYTO1gWjHy+KLIjRu2CLND090EfUQs2Hs2cVRRBvEBlcmvtxJ59B2pHSXMWJGjhVZk5VBTOS6svD2r7Cc2wGtZOVe9WBO9/DgtMyTvs= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587683932870307.7191155528624; Thu, 23 Apr 2020 16:18:52 -0700 (PDT) Received: from localhost ([::1]:44746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRl7K-0000Na-Ea for importer@patchew.org; Thu, 23 Apr 2020 19:18:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51360) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRl5U-0007EF-5g for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRl5R-0006mN-6A for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:55 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:44003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRl5Q-0006ic-Ec for qemu-devel@nongnu.org; Thu, 23 Apr 2020 19:16:52 -0400 Received: by mail-wr1-x441.google.com with SMTP id i10so8586602wrv.10 for ; Thu, 23 Apr 2020 16:16:51 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 16:16:49 -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=mDfF+nCaDRfOLKLYCWQdtmluZlHSpxwXCWsiYI5lMHI=; b=t/f/GBx0pXhXgn67L08pNOWEiH0EIcVkMbejMjrFOqPqqNyf9QHbdSu+RUs45cLBi6 WMiQpj5CvPHZ7nOAysUOp6ZD9Pk/TJzUAG5/sE2iYjYj3RtOMn8X9PUzuwXEVu8s/1Ap jUyZ5BelTvnV6tBp5drVGlbxLpOM10dtp79tma9yCDb5KnYxTBxv2yXjbakLypt3LCCt mtuOQxECzShAst3gyOWGUzePHlY6fuTuA6h7qw6/YvhxPF2ytNhcPgzkVQs8vg549PgU 7D4MgOUzMskU6LoTKpz48nnpWh8kZvSZLHkkg/4a42R032jGlo8xtzeipb+dDQKt2jPb Ck3A== 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=mDfF+nCaDRfOLKLYCWQdtmluZlHSpxwXCWsiYI5lMHI=; b=saC28COAKkeXpe4flf0WRC1Wopgdyh0KeksZ+gvg8PGjealdbuVQUeMm8bU3MN1era ycnRrL+JwNGw9bkHuywgKkMRyERjAEXTKJvFXEEG+B4A6xq0KJiN9iN9aB15laCHrd8r yujn/6aWLfDnWekDEJ4NJwTIBFlKFKEGKiRCyj152pHwv48ydjp39FvfVEJLQTFhwxMl BABcrxI/bMqCgpxQUxRVPvDLjY4bDeEnuYr8as1DWujpt9xc9qNi3T1R1M9KW7N2NsS0 0x6dlcLLp+IhChg4NdrFbm+xau/239IJ9uDQ2X5fQex3kdTZrWT/3RyjeJWwUbGt3XbU w8gA== X-Gm-Message-State: AGi0PuYL/kj7ici3iBPgOapEl7pIDCUiJityYbmMao7qdFs+gdta5P3I lL182CL35E8bxpsOvINCmWT73RFG X-Google-Smtp-Source: APiQypJ7LvwKNq1T5UUNg8uBXIEtPX985Bdg3zSd7Mk2zeGnu2ekcZGOLSoiZg45cVZef8qvvpbd0A== X-Received: by 2002:a5d:6504:: with SMTP id x4mr8067713wru.164.1587683810004; Thu, 23 Apr 2020 16:16:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 2/3] hw/net/tulip: Log descriptor overflows Date: Fri, 24 Apr 2020 01:16:43 +0200 Message-Id: <20200423231644.15786-3-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: Helge Deller , Sven Schnelle , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Log with GUEST_ERROR what the guest is doing wrong. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/tulip.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/net/tulip.c b/hw/net/tulip.c index 1295f51d07..470f635acb 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -172,6 +172,11 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct = tulip_descriptor *desc) } =20 if (s->rx_frame_len + len > sizeof(s->rx_frame)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: descriptor overflow " + "(ofs: %u, len:%d, size:%zu)\n", + __func__, s->rx_frame_len, len, + sizeof(s->rx_frame)); return; } pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame + @@ -187,6 +192,11 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct = tulip_descriptor *desc) } =20 if (s->rx_frame_len + len > sizeof(s->rx_frame)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: descriptor overflow " + "(ofs: %u, len:%d, size:%zu)\n", + __func__, s->rx_frame_len, len, + sizeof(s->rx_frame)); return; } pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame + @@ -584,6 +594,9 @@ static int tulip_copy_tx_buffers(TULIPState *s, struct = tulip_descriptor *desc) int len2 =3D (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZ= E_MASK; =20 if (s->tx_frame_len + len1 > sizeof(s->tx_frame)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: descriptor overflow (ofs: %u, len:%d, size:%zu)= \n", + __func__, s->tx_frame_len, len1, sizeof(s->tx_frame)= ); return -1; } if (len1) { @@ -593,6 +606,9 @@ static int tulip_copy_tx_buffers(TULIPState *s, struct = tulip_descriptor *desc) } =20 if (s->tx_frame_len + len2 > sizeof(s->tx_frame)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: descriptor overflow (ofs: %u, len:%d, size:%zu)= \n", + __func__, s->tx_frame_len, len2, sizeof(s->tx_frame)= ); return -1; } if (len2) { --=20 2.21.1 From nobody Fri Nov 14 12:16:41 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