From patchwork Fri Sep 6 17:59:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Peixoto X-Patchwork-Id: 1982008 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 4X0kXL710wz1y1H for ; Sat, 7 Sep 2024 04:00:02 +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 1smdFS-00009o-Si; Fri, 06 Sep 2024 17:59:54 +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 1smdFR-00008J-0U for kernel-team@lists.ubuntu.com; Fri, 06 Sep 2024 17:59:53 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (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 BDBEA3F5AB for ; Fri, 6 Sep 2024 17:59:52 +0000 (UTC) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-205428e6facso28178455ad.2 for ; Fri, 06 Sep 2024 10:59:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725645591; x=1726250391; 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=DSH5MvkbmSqjqMDn5wodPmEQ1mGlS83vQXWSLkTuwwR3X9CtKNbFTPZQeutTOc65Rf +RH4YfF82x/YpjTynvJiEhUREEjiienOJn1A6Cw1BId8E+9Lxo4AEHfNkretbSWJwK2o KDENPZ3/QG8KVRYcfmYCS/1ckFiHCpkvBB5cTEA136P13VU9JykTj5yqyFh/cKOmvf4u vxsNd+iYjyWjeIpjQ9GBCgGFPJctLyhfUL5zhbvqf+JxEUOua2FOmChVTkG/pfYbQhoz py5k3A8nfwX7aCTklaj+J/XMhTBJdpJfY/LQ6criRbJLIQuhMSkUvSyhDuslSdKpEjCw Y0KQ== X-Gm-Message-State: AOJu0Yxfa8H6NFT0IbDGK4M5fwIAz2BRZ3WI3eyPuxltZOQWH30XuD5O YDJB+xzrxxILQ727rFjE49kjoww3KBoxhWaSebEPM2Uv5qmGr+m1q57ZqzvAaFawEGkO6hZuXym dD29yrIp9jxkS4X3hWkVwrm8v0KnEBF61rUTyMGMZlLAfnOGiaGRRcIb0G/19VD+OZJUZJADDyK 0FZl1xOhCv/A== X-Received: by 2002:a17:903:230a:b0:206:c486:4c33 with SMTP id d9443c01a7336-206f0522330mr42168045ad.30.1725645590857; Fri, 06 Sep 2024 10:59:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZo3i1Z+0yA4ITWQ3FuvVoVWgeM6B4oJYZeQViDVOWbT9yu+febZZciVvwaznt04HYBVd3BQ== X-Received: by 2002:a17:903:230a:b0:206:c486:4c33 with SMTP id d9443c01a7336-206f0522330mr42167735ad.30.1725645590341; Fri, 06 Sep 2024 10:59:50 -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-206aea5554dsm45645595ad.235.2024.09.06.10.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:59:49 -0700 (PDT) From: Vinicius Peixoto To: kernel-team@lists.ubuntu.com Subject: [SRU][o:linux-azure][PATCH v2 1/1] net: mana: Fix RX buf alloc_size alignment and atomic op panic Date: Fri, 6 Sep 2024 14:59:19 -0300 Message-ID: <20240906175919.773606-4-vinicius.peixoto@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240906175919.773606-1-vinicius.peixoto@canonical.com> References: <20240906175919.773606-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; }