From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C37843B52E7 for ; Mon, 30 Mar 2026 09:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774863541; cv=none; b=t09d5cWEKSXrZXB+c1j033ImiatPqGfDcz9dzMlFCHc3GP26Yy2CzMO3LXzKGBaA36ln44LBvO/aUestUouQORxbTzwzoPBVypW/Olzt4dHKQCV/gqfqJ25aTzyUTVPkiBfWWMfZXjNSPB9DEHBCrWKo0XJm9xpAGbLb8JixIC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774863541; c=relaxed/simple; bh=qPgXOr4ZkOVqvLgawY0EULlZk//YObr2CkVwJ1NqcvE=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=PXg3sQbvsuhV2kjadLkrZjuK/ZbqcY4A9zoG1NqmFpp0K6rObI24/Byzs6CiQilTm0xEejei+XNMrsMJCp0DLQM8RflA28TSoPiuVmK8L1l2MJIi54sWcCxpt0D+mxEo/YoUecsr/vX5gV8Ql2u3xp50hyJAfkftJYxnTwMfLoY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=L3sjpqPu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="L3sjpqPu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA018C4CEF7; Mon, 30 Mar 2026 09:39:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774863541; bh=qPgXOr4ZkOVqvLgawY0EULlZk//YObr2CkVwJ1NqcvE=; h=Subject:To:Cc:From:Date:From; b=L3sjpqPuv4UrP4FLy/fcy8h4taKHjm+gztX2rYAKtsU1iN+8MqGcWGuJsH9jSw3Ak J1ojdFdT7522Pfb5Xg4fbpBsVVu6oSdrrI4cs/vLFxiT0GCOMujinKzkN9IlNFdD6b r/uqqeHRcDDmAF9BaF1thJHGuxdmNjYtJlW/Zyt8= Subject: FAILED: patch "[PATCH] net: mana: fix use-after-free in add_adev() error path" failed to apply to 6.18-stable tree To: lgs201920130244@gmail.com,kuba@kernel.org,longli@microsoft.com Cc: From: Date: Mon, 30 Mar 2026 11:38:41 +0200 Message-ID: <2026033041-settle-wackiness-fce1@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x c4ea7d8907cf72b259bf70bd8c2e791e1c4ff70f # git commit -s git send-email --to '' --in-reply-to '2026033041-settle-wackiness-fce1@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From c4ea7d8907cf72b259bf70bd8c2e791e1c4ff70f Mon Sep 17 00:00:00 2001 From: Guangshuo Li Date: Tue, 24 Mar 2026 00:57:30 +0800 Subject: [PATCH] net: mana: fix use-after-free in add_adev() error path If auxiliary_device_add() fails, add_adev() jumps to add_fail and calls auxiliary_device_uninit(adev). The auxiliary device has its release callback set to adev_release(), which frees the containing struct mana_adev. Since adev is embedded in struct mana_adev, the subsequent fall-through to init_fail and access to adev->id may result in a use-after-free. Fix this by saving the allocated auxiliary device id in a local variable before calling auxiliary_device_add(), and use that saved id in the cleanup path after auxiliary_device_uninit(). Fixes: a69839d4327d ("net: mana: Add support for auxiliary device") Cc: stable@vger.kernel.org Reviewed-by: Long Li Signed-off-by: Guangshuo Li Link: https://patch.msgid.link/20260323165730.945365-1-lgs201920130244@gmail.com Signed-off-by: Jakub Kicinski diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 9017e806ecda..dca62fb9a3a9 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -3425,6 +3425,7 @@ static int add_adev(struct gdma_dev *gd, const char *name) struct auxiliary_device *adev; struct mana_adev *madev; int ret; + int id; madev = kzalloc_obj(*madev); if (!madev) @@ -3434,7 +3435,8 @@ static int add_adev(struct gdma_dev *gd, const char *name) ret = mana_adev_idx_alloc(); if (ret < 0) goto idx_fail; - adev->id = ret; + id = ret; + adev->id = id; adev->name = name; adev->dev.parent = gd->gdma_context->dev; @@ -3460,7 +3462,7 @@ static int add_adev(struct gdma_dev *gd, const char *name) auxiliary_device_uninit(adev); init_fail: - mana_adev_idx_free(adev->id); + mana_adev_idx_free(id); idx_fail: kfree(madev);