From patchwork Fri Sep 6 17:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Peixoto X-Patchwork-Id: 1982003 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 4X0kJw4RsNz1y1D for ; Sat, 7 Sep 2024 03:50:08 +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 1smd5t-0006xp-0o; Fri, 06 Sep 2024 17:50:01 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1smd5r-0006wC-2j for kernel-team@lists.ubuntu.com; Fri, 06 Sep 2024 17:49:59 +0000 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (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-0.canonical.com (Postfix) with ESMTPS id BA7A23F5AB for ; Fri, 6 Sep 2024 17:49:58 +0000 (UTC) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-206f9b1bc52so8290275ad.0 for ; Fri, 06 Sep 2024 10:49:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725644997; x=1726249797; 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=k6U5KdMv2MD6r1/5S3qkK20pRm+KatczZg+FWMb9J28=; b=hAbhHOj9fW217uztmlptyV9WLJsqeICFwHW/n5+OOylkTmgd8afr7oN9J0j6ZxB3q0 OjkLQmByY0MlySiUWyryTIzqkqESRN+bs2bdwtk+D4K7dvplZw+eUvVmd/3QIwWOmwRr c35aSxLv5pN+I9PCPkG1g0hpcmEr8lAEWQwyQHS3thloMTaq/6e5KUjNRne5pRNA576U b2BH7krN7tklcq8qX3Kzg4R7P7JGTXul+xOX/qBZv0+hl9gBaIwPJ7ZgqMrbF/rvfqW3 blLOnnPnQ6dKHmdK9oc4NEQzsft4bh3n4AzNWN6s1qyLLGtEXOhRWohYir/H9at6ogR2 TZFw== X-Gm-Message-State: AOJu0YxXvacoU7wo3kL4LsFe20Auk44Y8LLuB4MZb07cH/7G7ggLKc3W UNbjqfkFjPWLQv/bKCP3pi9/91ZUMZMpP3Z06UE7zrvpK8AREXrcoW+/A9lf3e8fMhBnuUjeM11 JJp/xb22vCfd3pm0AawXDHCMqw7oesPmWtDctAKMY2DvE1Xgd58ZFRSOpFUv6tKBV5zVGeDBqBh fzLa34oqKIGw== X-Received: by 2002:a17:902:ea0b:b0:205:2d09:9a30 with SMTP id d9443c01a7336-206f04f1ab7mr35193045ad.13.1725644996751; Fri, 06 Sep 2024 10:49:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDcfGQeaaoWpQr1vFqPef/Xj2QY5F3NM/DQFqvR0gdp3INy9re/5Z3uS7BShvVm7Efb7oT9Q== X-Received: by 2002:a17:902:ea0b:b0:205:2d09:9a30 with SMTP id d9443c01a7336-206f04f1ab7mr35192885ad.13.1725644996380; Fri, 06 Sep 2024 10:49:56 -0700 (PDT) Received: from canonical.com (201-95-42-158.dsl.telesp.net.br. [201.95.42.158]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae912be8sm45725075ad.4.2024.09.06.10.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:49:55 -0700 (PDT) From: Vinicius Peixoto To: kernel-team@lists.ubuntu.com Subject: [SRU][o:linux-azure][PATCH 1/1] net: mana: Fix RX buf alloc_size alignment and atomic op panic Date: Fri, 6 Sep 2024 14:49:32 -0300 Message-ID: <20240906174932.772682-4-vinicius.peixoto@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240906174932.772682-1-vinicius.peixoto@canonical.com> References: <20240906174932.772682-1-vinicius.peixoto@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/2079854 The MANA driver's RX buffer alloc_size is passed into napi_build_skb() to create SKB. skb_shinfo(skb) is located at the end of skb, and its alignment is affected by the alloc_size passed into napi_build_skb(). The size needs to be aligned properly for better performance and atomic operations. Otherwise, on ARM64 CPU, for certain MTU settings like 4000, atomic operations may panic on the skb_shinfo(skb)->dataref due to alignment fault. To fix this bug, add proper alignment to the alloc_size calculation. Sample panic info: [ 253.298819] Unable to handle kernel paging request at virtual address ffff000129ba5cce [ 253.300900] Mem abort info: [ 253.301760] ESR = 0x0000000096000021 [ 253.302825] EC = 0x25: DABT (current EL), IL = 32 bits [ 253.304268] SET = 0, FnV = 0 [ 253.305172] EA = 0, S1PTW = 0 [ 253.306103] FSC = 0x21: alignment fault Call trace: __skb_clone+0xfc/0x198 skb_clone+0x78/0xe0 raw6_local_deliver+0xfc/0x228 ip6_protocol_deliver_rcu+0x80/0x500 ip6_input_finish+0x48/0x80 ip6_input+0x48/0xc0 ip6_sublist_rcv_finish+0x50/0x78 ip6_sublist_rcv+0x1cc/0x2b8 ipv6_list_rcv+0x100/0x150 __netif_receive_skb_list_core+0x180/0x220 netif_receive_skb_list_internal+0x198/0x2a8 __napi_poll+0x138/0x250 net_rx_action+0x148/0x330 handle_softirqs+0x12c/0x3a0 Cc: stable@vger.kernel.org Fixes: 80f6215b450e ("net: mana: Add support for jumbo frame") Signed-off-by: Haiyang Zhang Reviewed-by: Long Li Signed-off-by: David S. Miller (cherry-picked from commit 32316f676b4ee87c0404d333d248ccf777f739bc) Signed-off-by: Vinicius Peixoto --- drivers/net/ethernet/microsoft/mana/mana_en.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index d2f07e179e86..ae717d06e66f 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -599,7 +599,11 @@ static void mana_get_rxbuf_cfg(int mtu, u32 *datasize, u32 *alloc_size, else *headroom = XDP_PACKET_HEADROOM; - *alloc_size = mtu + MANA_RXBUF_PAD + *headroom; + *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom); + + /* Using page pool in this case, so alloc_size is PAGE_SIZE */ + if (*alloc_size < PAGE_SIZE) + *alloc_size = PAGE_SIZE; *datasize = mtu + ETH_HLEN; }