From patchwork Fri May 24 03:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cabaj X-Patchwork-Id: 1938772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VlqYv74Cmz1ynR for ; Fri, 24 May 2024 13:01:23 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sALAw-0001Wp-1Y; Fri, 24 May 2024 03:00:58 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sALAu-0001Wi-7B for kernel-team@lists.ubuntu.com; Fri, 24 May 2024 03:00:56 +0000 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 0AC063F6A7 for ; Fri, 24 May 2024 03:00:56 +0000 (UTC) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-792ca95e323so100295185a.1 for ; Thu, 23 May 2024 20:00:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716519655; x=1717124455; 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:message-id:reply-to; bh=e+zq0iMTkYUyg8FBJ3Bce1UL8IROottmRLTtVxK+fVY=; b=Ao4PqvgmZxqndAOALtaGI5nw1Xv5mBnWRX+/zcg7FRz09h9qNxQVvi2EWO2cmjmdWX Fa87Rfi7WCchfEgtznoxcPnZJ/iMKiImyb1HsuGjQgN/BhoNcv6Qy3yFuKwLfAOMLrA3 gjdsT5irdXJQ63VhAEb7KtIbLjHochd5AjxEHIfduZaIwJXsU5iifvcb7snimG+/NVXL A0jXa8q4g9vmjaWcGSHDQy/6rbQxBYH76vSY5IKKqYTV9wGvYZcNIkFo1eWRxByQyMnF 8DTeTVKgkvsZU+vwQor+jULFV0eI3Q/9YRcscngUpPDrNiCrd2rxK3hcTxsDgKD2Xn3s uVQg== X-Gm-Message-State: AOJu0YwmWPQ4hZ8zFQyNMhRVe3YF/tk0GgezVxnMZ1ztqP82ZS53pLM4 GC/5tWGR9SfYdFCjTBo002QC2pQqADLzmPKa+PofgVwZViD/9hDsp1naRZdSJbKSrUuVJ6aeUNl wMcpXqmwKj67JuJuxMnk/ZVVcIl/PUA9y94JoJopD2eLSkL8aX37sRb/0+VQi6VChNjeLk12M/U BAjE9momP6cQ== X-Received: by 2002:a05:620a:94a:b0:794:8de6:505f with SMTP id af79cd13be357-794ab1233e2mr95153585a.65.1716519655056; Thu, 23 May 2024 20:00:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW18pp88t0V87wommDoeJBS5cKDg0jh5LYQc+0TrUS/2g7xmAXfheqwHWqIbOX/ulBPP1UEg== X-Received: by 2002:a05:620a:94a:b0:794:8de6:505f with SMTP id af79cd13be357-794ab1233e2mr95151285a.65.1716519654463; Thu, 23 May 2024 20:00:54 -0700 (PDT) Received: from smtp.gmail.com (h208-73-92-250.mdtnwi.broadband.dynamic.tds.net. [208.73.92.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-794abcc0c4fsm24645785a.48.2024.05.23.20.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 20:00:54 -0700 (PDT) From: John Cabaj To: kernel-team@lists.ubuntu.com Subject: [SRU][o/n/m/j:linux-azure][PATCH 1/1] net: mana: Fix Rx DMA datasize and skb_over_panic Date: Thu, 23 May 2024 22:00:52 -0500 Message-Id: <20240524030052.1501265-2-john.cabaj@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524030052.1501265-1-john.cabaj@canonical.com> References: <20240524030052.1501265-1-john.cabaj@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: https://bugs.launchpad.net/bugs/2066992 mana_get_rxbuf_cfg() aligns the RX buffer's DMA datasize to be multiple of 64. So a packet slightly bigger than mtu+14, say 1536, can be received and cause skb_over_panic. Sample dmesg: [ 5325.237162] skbuff: skb_over_panic: text:ffffffffc043277a len:1536 put:1536 head:ff1100018b517000 data:ff1100018b517100 tail:0x700 end:0x6ea dev: [ 5325.243689] ------------[ cut here ]------------ [ 5325.245748] kernel BUG at net/core/skbuff.c:192! [ 5325.247838] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI [ 5325.258374] RIP: 0010:skb_panic+0x4f/0x60 [ 5325.302941] Call Trace: [ 5325.304389] [ 5325.315794] ? skb_panic+0x4f/0x60 [ 5325.317457] ? asm_exc_invalid_op+0x1f/0x30 [ 5325.319490] ? skb_panic+0x4f/0x60 [ 5325.321161] skb_put+0x4e/0x50 [ 5325.322670] mana_poll+0x6fa/0xb50 [mana] [ 5325.324578] __napi_poll+0x33/0x1e0 [ 5325.326328] net_rx_action+0x12e/0x280 As discussed internally, this alignment is not necessary. To fix this bug, remove it from the code. So oversized packets will be marked as CQE_RX_TRUNCATED by NIC, and dropped. Cc: stable@vger.kernel.org Fixes: 2fbbd712baf1 ("net: mana: Enable RX path to handle various MTU sizes") Signed-off-by: Haiyang Zhang Reviewed-by: Dexuan Cui Link: https://lore.kernel.org/r/1712087316-20886-1-git-send-email-haiyangz@microsoft.com Signed-off-by: Jakub Kicinski (cherry picked from commit c0de6ab920aafb56feab56058e46b688e694a246) Signed-off-by: John Cabaj --- drivers/net/ethernet/microsoft/mana/mana_en.c | 2 +- include/net/mana/mana.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 59287c6e6cee..d8af5e7e15b4 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -601,7 +601,7 @@ static void mana_get_rxbuf_cfg(int mtu, u32 *datasize, u32 *alloc_size, *alloc_size = mtu + MANA_RXBUF_PAD + *headroom; - *datasize = ALIGN(mtu + ETH_HLEN, MANA_RX_DATA_ALIGN); + *datasize = mtu + ETH_HLEN; } static int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu) diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index 76147feb0d10..4eeedf14711b 100644 --- a/include/net/mana/mana.h +++ b/include/net/mana/mana.h @@ -39,7 +39,6 @@ enum TRI_STATE { #define COMP_ENTRY_SIZE 64 #define RX_BUFFERS_PER_QUEUE 512 -#define MANA_RX_DATA_ALIGN 64 #define MAX_SEND_BUFFERS_PER_QUEUE 256