From nobody Sat May 18 18:27:46 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612969006; cv=none; d=zohomail.com; s=zohoarc; b=TZWQJrUEkfiI2/XdUQtAp9Huk5CCg8BAB6aYQLINeptQDGDvRUMGi3cCYRD4tyKv8aHv9KmLsKK7D/1Xu3utonUxb9DGibpfAnV40vLYCnt3n8SXMpr1uZ3vAas/ClVMYoBMeuPltoVWVkqesOLhqSk5XecSxVxGP/G3L53i7co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612969006; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+udZjA1UY3OqeCZ80mbbgAGzN4Wh0uK8gDwRxo/IVkQ=; b=ULoUNai/V6+GOMQ2m5ESaaN92kLUPCdg3RHfYZlsxmpkNqSt7LBJfVbVTQBVC7wcXVNU4BM0ufUyC8JSmdZIpUtpjYtXUvw0/zHVs1Tjq/QDN5mnhwjtiqHzhaH7lI4u3dJ932CGb5prFx4F9lsuCR3UHOg9r6TS3poAYBjtxH4= 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 1612969005989119.23938974551231; Wed, 10 Feb 2021 06:56:45 -0800 (PST) Received: from localhost ([::1]:47200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9qv5-0006NK-Ov for importer@patchew.org; Wed, 10 Feb 2021 09:56:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9qtf-0005rU-UI for qemu-devel@nongnu.org; Wed, 10 Feb 2021 09:55:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9qtb-0002pw-9J for qemu-devel@nongnu.org; Wed, 10 Feb 2021 09:55:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-jB2t9vJkPlmtYnxL_2a7Jg-1; Wed, 10 Feb 2021 09:55:07 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF6A979EC0; Wed, 10 Feb 2021 14:55:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.74.9.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD89D1A838; Wed, 10 Feb 2021 14:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612968909; 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; bh=+udZjA1UY3OqeCZ80mbbgAGzN4Wh0uK8gDwRxo/IVkQ=; b=SKRXwrAlxMIJE6yh3XPXXBQG3EXV88wOP9pqaJgoMf6S7EtPOynQ+99jBFgoaPB38ievJK tHPLrHWwA5L2XzKeXNolQ5LTFsts52UNSgZDrmdjhbxYi7HKr5NC5WsTYqlDZlui+QrkqE htCyMNm2ijY8KLzZgWZxpQ41eCne38Q= X-MC-Unique: jB2t9vJkPlmtYnxL_2a7Jg-1 From: P J P To: Jason Wang Subject: [PATCH] net: e1000: check transmit descriptor field values Date: Wed, 10 Feb 2021 20:22:58 +0530 Message-Id: <20210210145258.143131-1-ppandit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ppandit@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=ppandit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Alexander Bulekov , Cheolwoo Myung , Ruhr-University Bochum , QEMU Developers , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit While processing transmit (tx) descriptors in process_tx_desc() various descriptor fields are not checked properly. This may lead to infinite loop like issue. Add checks to avoid them. Reported-by: Alexander Bulekov Reported-by: Cheolwoo Myung Reported-by: Ruhr-University Bochum Signed-off-by: Prasad J Pandit --- hw/net/e1000.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index d8da2f6528..15949a3d64 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -667,9 +667,11 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *d= p) =20 addr =3D le64_to_cpu(dp->buffer_addr); if (tp->cptse) { + assert(tp->tso_props.hdr_len); msh =3D tp->tso_props.hdr_len + tp->tso_props.mss; do { bytes =3D split_size; + assert(msh > tp->size); if (tp->size + bytes > msh) bytes =3D msh - tp->size; =20 @@ -681,22 +683,26 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *= dp) memmove(tp->header, tp->data, tp->tso_props.hdr_len); } tp->size =3D sz; + assert(tp->size); /* sz may get truncated */ addr +=3D bytes; if (sz =3D=3D msh) { xmit_seg(s); memmove(tp->data, tp->header, tp->tso_props.hdr_len); tp->size =3D tp->tso_props.hdr_len; } + assert(split_size >=3D bytes); split_size -=3D bytes; } while (bytes && split_size); } else { split_size =3D MIN(sizeof(tp->data) - tp->size, split_size); + assert(tp->size && split_size); pci_dma_read(d, addr, tp->data + tp->size, split_size); tp->size +=3D split_size; } =20 if (!(txd_lower & E1000_TXD_CMD_EOP)) return; + assert(tp->size && tp->tso_props.hdr_len); if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) { xmit_seg(s); } --=20 2.29.2