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 6BC65C6FA8E for ; Tue, 27 Sep 2022 11:22:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 62FB584C85; Tue, 27 Sep 2022 13:21:52 +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="oVX0kxvP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72F3984C4C; Tue, 27 Sep 2022 13:21:45 +0200 (CEST) Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 D208F84C63 for ; Tue, 27 Sep 2022 13:21:41 +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-ed1-x530.google.com with SMTP id y8so12737413edc.10 for ; Tue, 27 Sep 2022 04:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codasip.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KvZZ372iK0cee+766ODcUQkJq23qJkyci9bckgFP2XM=; b=oVX0kxvP1QPmBgObCHp/fhxWnuEFC5ayc73UP/Wdz+t5mvBCFxAH1GKEM2m/LGzwHN v+PcU/S6fraWaNJjCHF1FUdzHDARrJpNgOSCmqYFCe/f50daA64Px+eSRfaDwqzMDAd+ SOiSjiG9GRLHh4qOSi4hg18NJBtl0AewQn2v3PtrODBjhxmmD6T72/ZENbphCXFciMz8 0AE4WwUYEOpfwnGsdx5uCz3pnlYtH85DQGkya0gyhrLQk77YMHXokeykcP68ZzXnehV5 tZsnXim2lXAURYAClLbWHciWPKkMay5T+sRjHxB3E1/nfvEsonrSdV5Wt6gi4VNgMMc+ +Yxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KvZZ372iK0cee+766ODcUQkJq23qJkyci9bckgFP2XM=; b=SHRYKDRWQbw3bdNDBDSl8NjzsSx3kfD2vf+cMJ73+3zb0eFG/nyWYjnwGbDf7NorgK IKIAUuReA8gPAbo9I5Z98o+ShNlukyXscEZOuHb/Iaa9Zec29qgYqob75UihQ5MTtlL6 6tQYfvNnA3jxwWymKX9Obpr6E5beKeKDkKVtCbLKqUEi0CKSMNDiwRUHHoZPjaXGCxEn g8iL63gMmlhtyEApv3sEVrrkyI6xjZ9jMeZY2438X38CaQ8G4LpBOauL6+cYp3YDJl6Q MT443FTZz/KtZ2drIGe42jUA9PzR3pAJ78f7D2w6gs+VlybxSunOFjcMxQnBqgollMhO MPnw== X-Gm-Message-State: ACrzQf11jZYozeUwWLb83xRiOYdasRd6TPTZCjLednkq8YSknWp8iW3P js4VhSE+29rh3qjj8Cq9ftjmRxNFA2E16vm3 X-Google-Smtp-Source: AMsMyM5Gv1vglESdVeNGG327hEpzivXHGG7XyX+PpT+ffdv0iDMPLtQvAALlN8Sj54XIh8aU67NURA== X-Received: by 2002:a05:6402:3784:b0:453:9d2a:771b with SMTP id et4-20020a056402378400b004539d2a771bmr27156609edb.353.1664277701146; Tue, 27 Sep 2022 04:21:41 -0700 (PDT) Received: from nb76.codasip.com (fw1.dino.sk. [84.245.95.252]) by smtp.gmail.com with ESMTPSA id i1-20020a170906a28100b0078238c1c182sm622523ejz.222.2022.09.27.04.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:21:40 -0700 (PDT) From: samuel.obuch@codasip.com To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, michal.simek@amd.com, Samuel Obuch Subject: [PATCH v3 3/3] net: emaclite: fix handling for IP packets with specific lengths Date: Tue, 27 Sep 2022 13:21:03 +0200 Message-Id: <20220927112103.155689-3-samuel.obuch@codasip.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927112103.155689-1-samuel.obuch@codasip.com> References: <20220927112103.155689-1-samuel.obuch@codasip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Samuel Obuch 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 a4851ad36f..16ba915fba 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -517,6 +517,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"); @@ -525,7 +527,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