From patchwork Fri Sep 6 17:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Peixoto X-Patchwork-Id: 1982006 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 4X0kXB62ZMz1y1H for ; Sat, 7 Sep 2024 03:59:54 +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 1smdFL-000053-7E; Fri, 06 Sep 2024 17:59:47 +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 1smdFJ-0008W5-9t for kernel-team@lists.ubuntu.com; Fri, 06 Sep 2024 17:59:45 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 157C53F5AB for ; Fri, 6 Sep 2024 17:59:45 +0000 (UTC) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-2d8abc9b3e4so2653660a91.2 for ; Fri, 06 Sep 2024 10:59:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725645583; x=1726250383; 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=BJRLs/ZEmSBFacUK+sv4xdxCTNOY8tdaB2ttPWS0otMq2ECZ+3ovF0/r8Ea1kTg9w0 XA4P3raOa2hVZBJhpNZe8IXz0ol7LvKPnUIg556gVlr81s9mUvu9qiPRMG8B/7cP6O7i xCSesHgJgZxb46dZYP+BjfTAYDyWYwfRkD3ltjt1b8quSaJcxJiZ4pPECNfzS5uK/6J/ bh7Il2GSEkmrBnK6vuYiGFDYSl6wgpVusSijW1+iBpe+Jmcfdeq+0tXdOSwEDzlqeZpL rqN8tLgY50IDJMqz5YO4zwWu5fu3rex6vA2h9VrQzBltMxNKMDneZMjuL6dYPo44305P e6qg== X-Gm-Message-State: AOJu0YzWBkiIgRW1V4SsJQbtLGt5+aK1TWlb3RLYtN8SDqw0Jz9g1aJv zkE3SLW0NHl/Z+LbrgFpGPwYRklqzSnfjFJJiz6tCNgDMeE5CbtbukmhlaKdj4xYe/Fw7NWuUjv NpPxWAadA5O1PjRtPLyVrrvMMw8k+/T3ODxDF6ywpRFuEHlF6xHJjSrid0vPqkYLjXzFcsZEQdc g16BJgnvUI8Q== X-Received: by 2002:a17:90a:3486:b0:2da:89ac:75b9 with SMTP id 98e67ed59e1d1-2da89ac7679mr11628489a91.11.1725645583154; Fri, 06 Sep 2024 10:59:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtxcOdunWcw172qvQqgiU3OdQcurYDD+5rPHyLQVoBfC/YWJEQ7BcUV5NQD79d7Ago9UbDHg== X-Received: by 2002:a17:90a:3486:b0:2da:89ac:75b9 with SMTP id 98e67ed59e1d1-2da89ac7679mr11628466a91.11.1725645582609; Fri, 06 Sep 2024 10:59:42 -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-2dadc0317c0sm1909899a91.19.2024.09.06.10.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:59:42 -0700 (PDT) From: Vinicius Peixoto To: kernel-team@lists.ubuntu.com Subject: [SRU][j: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:17 -0300 Message-ID: <20240906175919.773606-2-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 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; }