From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FB6A38F22D for ; Sat, 4 Jul 2026 06:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783145722; cv=none; b=dvGXBiD0pM50AzYgoB8/sBa3QM4LsJW3d7cQtZTWJ3dqh3WOdDDEhOilr3B+Mv72n/QBnSN1qygZL9dcr7V76Vrc9jjTd0BGc2opKeNKjx3hcA7FkXG3lsf/UtntoCPsx95IBnInO5UZ9elaaoHbRpi0U48+pFku8+LNoCL54Y4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783145722; c=relaxed/simple; bh=t9a5ssxdpXDVyO9sUclJsBFNl0rY6QGQUgOZ+6cTNJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XQMQcxEGu8faHDLnunPGXINY9cgqnO8UroZ6VrVY9kY1XJnBFifqgD26DFi89iAh7bm4IuARu+kAQkg80Imhesi49oHbgi1Z2NQCYZewvl8TfyIgOVq9Ub38p5qT/YpaHOrE6O6K4fyINO4pKcHMn1gXaY1GYGZu6CA/n3Vxolw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fRb8dT1i; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fRb8dT1i" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-37d70036426so815224a91.3 for ; Fri, 03 Jul 2026 23:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783145720; x=1783750520; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Fx1WqksvuISZjKB8qjiAsted/XID7FOi3iV53rUECy4=; b=fRb8dT1isvDxRHNuLyjJl3Yw0Xfemr6i74eotmBAgki2dC9ug/++JpTmiDvkGYVZAm UZsszdc3e9acoZr8zK3sUXvMEiny3N0uPf9QF2ZSedZsvCbxM0l42+uLv3RqnVnqwc+2 IDIKdJLVEJN2INwvjgSMI3THGfbVbvOl6SEuHfm1cHil7CRG1W4w+oh1je76pdZ+51zD eyJ6UCGZLyS4D7MVZ/WsuyiEpSIoY9AyACuwjPergHSJdtv9TjEs21pRyYm5viDFVxoa 4YhLQ/W6OOoIilEVuWcAUPKu/DsxIRPYS9xg2j2xws2SrU7PCUMxYcJJ9wHfhVEzutDC 6Djw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783145720; x=1783750520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Fx1WqksvuISZjKB8qjiAsted/XID7FOi3iV53rUECy4=; b=ecQNKzSkBcL0G7xTqPm4lcrVXTBUYnAQ1ZqQ+wrobsTz9NPWuvwTWkblo0vi7HWvnE 4JXgmxivkaShvE9gl3qmK8Rq1lWKCZ23q7hozcGlyj/m8sKYatDugKyNaNX0yU/4QqAu OnpSbxXJauu5vc31HYc1LXrf9MlEOXpNURO6TnGDK1y243aorT+8V9nGUiciZn+S9kQ8 0fG0IuBclwd+VTf5gX5WfgIobNOC7jkGdC8HPHSs3Wha8oHathTJRfja8pJfEvFjWWFq tDD0ZcDESRjJWzEEEGTpEvnttiJX2MCxPfDCGVa5hXVbConskfvjQo67pxVlZKI7Ow/n J5JQ== X-Forwarded-Encrypted: i=1; AHgh+RpEsAG3fJ+DaxNvf9p0gfjyxcLih0ZkQ6HhvwkOArppmsE6eFgJGn5jCU57s5ZdyMLsMeUj80TzTe6DhSk=@vger.kernel.org X-Gm-Message-State: AOJu0YxwBB8vBkYEWLSRzx6JWmcAbbWFB9Aw72PKZks+vU4X8CmUbSEH ZplD5JIoBAqL7SsofgeUl/KW+MzBG3I18wRVA3hrMiO0GmcHxRhGDVNk X-Gm-Gg: AfdE7cmvJ54dGPZehvC2iGUb3g5841XTOGaBF8rNMwyRBBFlN5kmYWXaSWbOrUlQ+Zy fzKh549yqw+1PSENKvurg8qYUne+PeQf/Rlo5wVZgnoFC5iQR6DJxSYswII8CRE268JAfyl8fjd OQiqoKZ1S4rBxPokCMcMTsBQ1UNsRRL8MG9A/CH/MEZFfsx/wBGA1xOuWtGxuUiHTvOKcSIEjgP efHv9NdZ7mYaQw9/akMpz8hpmEMmZ8law8F3wF+1q7cKnB2TsxlQVeaLlOKq/NakTpCFxI4IcHa z6CPRFF/FWXh4rRDoZEJ/nAjO8xYOjJ5NuT70wQNlqJg6mLqWXOISCwIYEglR3ohvNO+nIYdOb8 e7uoKKJJD/FUAZvFFih/17SLw6xgZiXtQ86gDUwMlue5LpNSs8OIr01vh5VKam72I9KHzWCOBiR RGZxnQhg3DQt5aKnmWbKqP9YzhsxP7u+M6izJrEw== X-Received: by 2002:a17:90b:3a50:b0:381:149:cf91 with SMTP id 98e67ed59e1d1-3829f2f84b2mr2256768a91.26.1783145720262; Fri, 03 Jul 2026 23:15:20 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38127ae6e2bsm1983825a91.2.2026.07.03.23.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 23:15:19 -0700 (PDT) From: Maoyi Xie To: Veerasenareddy Burru , Sathesh Edara Cc: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maciej Fijalkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 1/2] octeon_ep: fix skb frags overflow in the RX path Date: Sat, 4 Jul 2026 14:15:10 +0800 Message-Id: <20260704061511.2350737-2-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260704061511.2350737-1-maoyixie.tju@gmail.com> References: <20260704061511.2350737-1-maoyixie.tju@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit __octep_oq_process_rx() builds an skb for a multi-buffer packet by adding one fragment per buffer_size chunk: data_len = buff_info->len - oq->max_single_buffer_size; while (data_len) { ... skb_add_rx_frag(skb, shinfo->nr_frags, buff_info->page, 0, buff_info->len, buff_info->len); ... } buff_info->len comes from the device response header (be64_to_cpu(resp_hw->length)). Nothing bounds the fragment count against MAX_SKB_FRAGS. data_len can be close to 65535. buffer_size defaults to about 3776 on 4K pages, so a full packet yields about 18 fragments. That is one more than the default MAX_SKB_FRAGS of 17, so skb_add_rx_frag() writes past shinfo->frags[]. The fragment count is now checked before build_skb(). A packet that needs more fragments than the skb can hold is dropped. octep_oq_drop_rx() consumes its descriptors like the build_skb failure path. The same class was fixed in other RX paths, including commit 5ffcb7b890f6 ("net: atlantic: fix fragment overflow handling in RX path") and commit f0813bcd2d9d ("net: wwan: t7xx: fix potential skb->frags overflow in RX path"). Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support") Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Maoyi Xie Reviewed-by: Maciej Fijalkowski --- drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c index e6ebc7e44a..bdbed58c7b 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c @@ -453,6 +453,15 @@ static int __octep_oq_process_rx(struct octep_device *oct, octep_oq_next_pkt(oq, buff_info, &read_idx, &desc_used); + if (buff_info->len > oq->max_single_buffer_size) { + u16 data_len = buff_info->len - oq->max_single_buffer_size; + + if (DIV_ROUND_UP(data_len, oq->buffer_size) > MAX_SKB_FRAGS) { + octep_oq_drop_rx(oq, buff_info, &read_idx, &desc_used); + continue; + } + } + skb = build_skb((void *)resp_hw, PAGE_SIZE); if (!skb) { octep_oq_drop_rx(oq, buff_info, -- 2.34.1