From patchwork Fri Sep 6 17:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Peixoto X-Patchwork-Id: 1982001 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 4X0kJm1v1Vz1y1G for ; Sat, 7 Sep 2024 03:50:00 +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 1smd5k-0006qY-CR; Fri, 06 Sep 2024 17:49:52 +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 1smd5i-0006py-47 for kernel-team@lists.ubuntu.com; Fri, 06 Sep 2024 17:49:50 +0000 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (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 F22733F0F8 for ; Fri, 6 Sep 2024 17:49:49 +0000 (UTC) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2d8e7e427d5so2897486a91.0 for ; Fri, 06 Sep 2024 10:49:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725644988; x=1726249788; 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=Df6P09lw6HwkCusVSm/aGiwQahG52buMH9dGTjfqxWA=; b=uxd/LH1oNeyF6KhdUkiwXWfPTF/l0abltzHL6fZstikIKy5sjX/EF0tPUyYw+JhbOM lZieX1aTuZjVWnUanpD5HxFtIXtH2XiyLaxW6mETBujzxRANsKGOIOvtUfvYCkLossw4 ZP1SKbG+K482qnGHUVuJQRI/LjQCgQtNA/HEQCbqRFEuxEgqG8xFYyVWAJPR7UOyMnZD BkmBjqqBer33PP8y34du4tLHNJSyqlnSbZZLGJpn4qSDizYn5N4pRSc5qS9gKNLYXmwB 2kNisYlPGAIo3vw8ZbMwOVdyyF9la7x5nNTGRmQavIv+frKd751tfDpNgkstWNVl/upv EJ8A== X-Gm-Message-State: AOJu0YxxlmdbB+YjrGKrVTuAJUTx+Fs8T0Ibz1qCbILfRCY/lfnUS/xD 38k3VTwiEpT2hvGjz901dtN/oHTmhxugOemPRQ64BG/zCYNFfpU8nHijMjvZuFepRok42RZZDf2 EmokZRqN5Tl6XMU7asMBYRrnRKfz2Rfy4LEm/v1oAgDdfP+NFJ5ZHqnds+lQ5nT17vAhWuUsMjG CilxhwadH1Jg== X-Received: by 2002:a17:90b:3cce:b0:2c9:6abd:ca64 with SMTP id 98e67ed59e1d1-2dad506f880mr5602894a91.9.1725644988008; Fri, 06 Sep 2024 10:49:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMWaOdOQ56NHp4ykCLAG+0ZOrNQoROQ9IVzKsnvxFEYYdR/YpK4m25OTsm0O0UnOC9s+MveA== X-Received: by 2002:a17:90b:3cce:b0:2c9:6abd:ca64 with SMTP id 98e67ed59e1d1-2dad506f880mr5602866a91.9.1725644987428; Fri, 06 Sep 2024 10:49:47 -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 98e67ed59e1d1-2dadc02daa6sm1909753a91.17.2024.09.06.10.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:49:46 -0700 (PDT) From: Vinicius Peixoto To: kernel-team@lists.ubuntu.com Subject: [SRU][j:linux-azure][PATCH 1/1] net: mana: Fix RX buf alloc_size alignment and atomic op panic Date: Fri, 6 Sep 2024 14:49:30 -0300 Message-ID: <20240906174932.772682-2-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 503e1b6d60e5..f9ae921999e8 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -486,7 +486,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; }