Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C79A1C43334 for ; Wed, 13 Jul 2022 14:02:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 10DCD84015; Wed, 13 Jul 2022 16:02:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=codasip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=codasip.com header.i=@codasip.com header.b="EajMvxDo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0BC9C832DA; Wed, 13 Jul 2022 15:56:21 +0200 (CEST) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6D61D83E4C for ; Wed, 13 Jul 2022 15:56:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=codasip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel.obuch@codasip.com Received: by mail-ej1-x62d.google.com with SMTP id l23so19995929ejr.5 for ; Wed, 13 Jul 2022 06:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codasip.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qfwtu9ssRSWD6AZPRhMCObeuCuffvArK+T0/bd/gt6Y=; b=EajMvxDohki8GLI/5ZdaL20gPL21hT5+X8YcxpmIiVFuQIrfH4LHyhWY9zIx02eX8l igtO3HRByHZqgHcqCXQbh7DTUu16cWL2M2NUJdv5+ZDXC9PiFIKKApNW+RBSp7M1rABy X1rTOf6N2qnM9NTCC7EpDmf6LuDQ3pjYE/Zn5Ir8Tbc4CD4Br1GuTF6nVDjNGFHQpyTy 26KIwNynCpYaMAEPrVDSGs2BzUDgP2drR3Yrq2peBA4Mm0IInE7ousoJM71ky4978Ibx s9NqulcaqwR0CNw7/tUI8uu8g6MXOoPuWVqnKoCtHKM1+yp6yv6s4+9PbbVMtATobuRH /D6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qfwtu9ssRSWD6AZPRhMCObeuCuffvArK+T0/bd/gt6Y=; b=muFUUH/+NML33kzT+jai1D71E2UC7q7xo21DWivE2jqMvWq2PKeMIaPEgPN0GsrYMY 4gfHijrNjVJHmtlUE8w0D3NxtTEJ5Ih6igrocHiokWl53lYNimYHrRP5qGzQ5JNYIDpC Mb9+jcfuzPF0tP5qO9nNOyjcetWX7QvPot/0VkXyk4EqNO7Z6dP7FFgxlTWkK3CBHdy9 Z48CiV2fDHtokHpwZ5Eh9ew+KWibn+wJdIrv21/nqcxKXQMxcRUsDgrfeBUbfTRPwwpe S7xbiQbk6rZEqaDOKy192jJ40xe6aar/fdFvOCEvApyicO42uXofSgZcZ9HBP/JJogP4 qh7Q== X-Gm-Message-State: AJIora8F7OfEWLv8qO5nUUv8Qg/51gGE6ycUNsZuL6B+sJVoKw8AjTYl 63m6XwFZ5RGEGOZt3N53I/G4iUuMoU+4Iw== X-Google-Smtp-Source: AGRyM1vETseZReWtQRNx4QgN/R9/bc/+bXSCVRZKPcD9rw4j04CKkZmsIU2+EAKzChGCNLV6RBbejw== X-Received: by 2002:a17:907:2887:b0:72b:68ce:2fff with SMTP id em7-20020a170907288700b0072b68ce2fffmr3616896ejc.423.1657720576700; Wed, 13 Jul 2022 06:56:16 -0700 (PDT) Received: from nb76.codasip.com ([193.85.186.210]) by smtp.gmail.com with ESMTPSA id h4-20020a50ed84000000b0043a85d7d15esm7907531edr.12.2022.07.13.06.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 06:56:15 -0700 (PDT) From: Samuel Obuch To: u-boot@lists.denx.de Cc: Samuel Obuch Subject: [PATCH 3/3] net: emaclite: fix handling for IP packets with specific lengths Date: Wed, 13 Jul 2022 15:52:04 +0200 Message-Id: <20220713135204.233268-4-samuel.obuch@codasip.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220713135204.233268-1-samuel.obuch@codasip.com> References: <20220713135204.233268-1-samuel.obuch@codasip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 13 Jul 2022 16:02:04 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The maximum length is capped similarly to the emaclite_send function. Avoid integer underflow for values of ip->ip_len < 30, the minimum length of an IP packet is 21 bytes. Signed-off-by: Samuel Obuch --- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index de7a2dee0b..21c450ec46 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -518,6 +518,8 @@ try_again: length = ntohs(ip->ip_len); length += ETHER_HDR_SIZE + ETH_FCS_LEN; debug("IP Packet %x\n", length); + if (length > PKTSIZE) + length = PKTSIZE; break; default: debug("Other Packet\n"); @@ -526,7 +528,7 @@ try_again: } /* Read the rest of the packet which is longer then first read */ - if (length != first_read) + if (length > first_read) xemaclite_alignedread(addr + first_read, etherrxbuff + first_read, length - first_read); -- 2.31.1