From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 4E62238D3E3 for ; Sat, 4 Jul 2026 06:15:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783145728; cv=none; b=tdr29wZXWuhNjStttBmJD13qCqlJ1vA3oP1xMft+D9hzTr7FankL44sAy3rF3H6T9Qh6vqSs5et5G3bqkxaZxEPcV9HPmty7mi/A8Ytc/cQDE3pig+6k0SN2VSGY/JubX1a+XHHW4sFD+K9qKobIBUwyJAc3JSjIu8VqQzgFmCs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783145728; c=relaxed/simple; bh=TiLsgiF9D1zaS0XWGamni2xuyhVi0f9tNKG3ox9Xkl4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iApINLMin8YNI7ZN7xC5lnvUFUfioluofytZO3Nx0tu38804gRCJqscsjXwGTmxQ5E74N2k/jbus/31dK1FwxgBPnrTkphJHhexPPBMrunbOD/TOHv/X1WBmFp9LSEbOe+VdP9gfJg1hWoT+oc8JCrWArUfIh79WdY0lnquTfOM= 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=p66X7s8F; arc=none smtp.client-ip=209.85.216.47 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="p66X7s8F" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-381216921aaso1150591a91.1 for ; Fri, 03 Jul 2026 23:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783145723; x=1783750523; 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; bh=Y1QMnSMN4LeVAhN51TBt+vF95rU9z7m18HWe4vyd23k=; b=p66X7s8FPgESfMffAGdIainaXdxr9z+bx/qAhXt3uMMQ1/ge5ZUxFA/DZC9eb9/BFM dmcMh2WHr3eXCENk6N0P0mULqrxEHtuOKcld/JsQUo43WyNdFUtOp1gXjNy8iKg2fZdU R4Os2+R8LZFP4Ggma4kIryOc6J/VPcPAjuqhAOfHTsK3WrshWeYUb5cd2xBWRfQkZH0i Mq64r86ADZYsfzj2jVONBHg9ny2hmKs4eVmEiXQWe/1lqOzTl2NkiDUHQWLZmCFdgOrz 7Ek6xzoUhWlAEXhfqgHW/3ZW5A9qqbI6ll3hqAk/QeHFrM8ammRIqbAvOxfJZ2pSIMlO 7iEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783145723; x=1783750523; 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; bh=Y1QMnSMN4LeVAhN51TBt+vF95rU9z7m18HWe4vyd23k=; b=chsNIZ1+EWlCzK4eW1MNioIhLFMTED2/hDbiwRiKmVcgpwI7cLG5k81MEH5V4J0UjH elff17WlG1wvKTymXtZkqr+axoMmoRpQEks34oHw8BMi+vsJWTFbCHKMltbipkiNXrQV XRY/grX3bC2yLAl2L7KLFjQZSgspzDI1xsEktTvzQdTo+JmQ6dYHh3zqB7xjd1XmiUit 4Os95+W3Z2TkjnVZ5AqH3gwJVvgLh+9NY3a8td1iLmCQejoxaIjJ/Leu9nn2lwkYbqIs kKkiLsJiRicc4Z+viuN7mRtxKSjJve/Ma/rOtpHlm4GTqHfYL/5NfYmKCug/SckJlknT WzBQ== X-Forwarded-Encrypted: i=1; AHgh+Rrv0S5KtJRfWKCyDcNXiEtf5s3qUmKC17FGnzC0hv7nh+N00shXNaXyBnQ+0jlkmNC679w+Allrgh12poQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy13J697xw2Os39wKefDQ/iDB9MIYFvx4UUk1QO2jkHaN9csW7X Sdz5DZyhP7hJKKTMItxrB1wTbEuYStoQaJsVN3gKZ3l/+Itqn0g2W/gC X-Gm-Gg: AfdE7cmS9OEbsYYhe2dvb+V18FfUhAPntKiJZ5ZA4VxCyrqeli2tiXzIlpi5mwxQApm xeARdh/7PWZ7euWXaepqaCpGJqsa5OvKAjqSmde22MNOQBLWFs0CyjREk7G/1VcvtB6ZfC+B1NO CAx3g43qZEV1/qHOkoBDh4/tBF/lgJwgDzapR18y8FzYKKSsqlwiTHU3QzbBe3C/hIBmta4eMQX jwAHQ4CInpQIZO3P2l0WGvRV7BJwzZ3jhwzTTvkOrOVatVyG/6avo747ZulD4lVEIfgP0znqRyf MXyW8LonMo2ShC6HYQ3L1nqyH2ZNUnrsSYw5tkJUD40Im3q7dxTovecEgL2pok1k+9sw6u0FIvz Lgq8FzAPOskuOuzwdRAih1qFkMehIE2GwfEn49lFG8jl2HT2R/ik4mtaFKNwX9a/+JmcuK/i/PQ QgN1Zu7mdbYTDyWvfx1wbkUKjPjBYgLraFsW48Sg== X-Received: by 2002:a17:90b:2743:b0:37f:e1af:df22 with SMTP id 98e67ed59e1d1-3829ef00938mr2430492a91.17.1783145723348; Fri, 03 Jul 2026 23:15:23 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 23:15:22 -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 2/2] octeon_ep_vf: fix skb frags overflow in the RX path Date: Sat, 4 Jul 2026 14:15:11 +0800 Message-Id: <20260704061511.2350737-3-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_vf_oq_process_rx() has the same unbounded fragment loop as the PF driver. buff_info->len comes from the device response header, and one fragment is added per buffer_size chunk with no check against MAX_SKB_FRAGS. A long packet yields about 18 fragments, one past the default MAX_SKB_FRAGS of 17, so skb_add_rx_frag() writes past shinfo->frags[]. The fragment count is now checked before napi_build_skb(). A packet that needs more fragments than the skb can hold is dropped. octep_vf_oq_drop_rx() drains its descriptors. The napi_build_skb() failure path now uses the same helper. Fixes: 1cd3b407977c ("octeon_ep_vf: add Tx/Rx processing and interrupt support") Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Maoyi Xie --- .../marvell/octeon_ep_vf/octep_vf_rx.c | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c index d982474082..aa77b673ae 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c @@ -357,6 +357,29 @@ static inline u32 octep_vf_oq_next_idx(struct octep_vf_oq *oq, u32 idx) return (idx + 1 == oq->max_count) ? 0 : idx + 1; } +static void octep_vf_oq_drop_rx(struct octep_vf_oq *oq, + struct octep_vf_rx_buffer *buff_info, + u32 *read_idx, u32 *desc_used) +{ + u16 data_len = buff_info->len - oq->max_single_buffer_size; + + (*desc_used)++; + *read_idx = octep_vf_oq_next_idx(oq, *read_idx); + while (data_len) { + dma_unmap_page(oq->dev, oq->desc_ring[*read_idx].buffer_ptr, + PAGE_SIZE, DMA_FROM_DEVICE); + buff_info = (struct octep_vf_rx_buffer *) + &oq->buff_info[*read_idx]; + buff_info->page = NULL; + if (data_len < oq->buffer_size) + data_len = 0; + else + data_len -= oq->buffer_size; + (*desc_used)++; + *read_idx = octep_vf_oq_next_idx(oq, *read_idx); + } +} + /** * __octep_vf_oq_process_rx() - Process hardware Rx queue and push to stack. * @@ -431,25 +454,16 @@ static int __octep_vf_oq_process_rx(struct octep_vf_device *oct, struct skb_shared_info *shinfo; u16 data_len; + data_len = buff_info->len - oq->max_single_buffer_size; + if (DIV_ROUND_UP(data_len, oq->buffer_size) > MAX_SKB_FRAGS) { + octep_vf_oq_drop_rx(oq, buff_info, &read_idx, &desc_used); + continue; + } + skb = napi_build_skb((void *)resp_hw, PAGE_SIZE); if (!skb) { oq->stats->alloc_failures++; - desc_used++; - read_idx = octep_vf_oq_next_idx(oq, read_idx); - data_len = buff_info->len - oq->max_single_buffer_size; - while (data_len) { - dma_unmap_page(oq->dev, oq->desc_ring[read_idx].buffer_ptr, - PAGE_SIZE, DMA_FROM_DEVICE); - buff_info = (struct octep_vf_rx_buffer *) - &oq->buff_info[read_idx]; - buff_info->page = NULL; - if (data_len < oq->buffer_size) - data_len = 0; - else - data_len -= oq->buffer_size; - desc_used++; - read_idx = octep_vf_oq_next_idx(oq, read_idx); - } + octep_vf_oq_drop_rx(oq, buff_info, &read_idx, &desc_used); continue; } rx_bytes += buff_info->len; -- 2.34.1