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 DF18D3B4EAC for ; Mon, 30 Mar 2026 09:39:04 +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=1774863545; cv=none; b=TprVKp0KVniC9j4bsTSMm7X0jiHaquwuGU5SC1AO8AsJiUc4UWMXZOQz0GLckwZRYqUkvrpTIPaWXpqXiIZh/KjUspQSt3CC8BMvv1Ai9krLnclP2Fy5eMNtbaOA4FKV/uIxKeFKyyS7iWvB1xR0gJgvyA/1ffnJoPoSdL9zptQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774863545; c=relaxed/simple; bh=nVlN9Wo8I6nSbhZHao5c7t4ou5VjHNQpIZzRedZNuYM=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=oVj6HYiuFQaEz5i8i7B+DmwDI9ZIflcN/jj5OLnWeID5dFyx++GPE7sh+OAyd7XxHO7IfbGirbmmHv/aCGiH5mqD5c6mVUAuWPKl4xpxU2uVbHkeg8+NTPkrBRQa8nGZ66XPQD9p+iAkd+YX3NffEjIeqGu50fYkXSgAcZnDF8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tgrqS4hb; 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="tgrqS4hb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA189C4CEF7; Mon, 30 Mar 2026 09:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774863544; bh=nVlN9Wo8I6nSbhZHao5c7t4ou5VjHNQpIZzRedZNuYM=; h=Subject:To:Cc:From:Date:From; b=tgrqS4hbRIulPPp89Nx11QtY4ky/5bvPNiuQKgisKh/iDciEorePk4QnS6cLGu0FI LFYuOJPWYP8GqFmxpSJT58a6SCOHXAoJ9JfWf09ksyIkUmoiX1vSAk/0+iH8+FOmuv Y+8bmf+ukyy9xmZbDbQbvCYXPBC5NEoZYFHwwveU= Subject: FAILED: patch "[PATCH] net: mana: fix use-after-free in add_adev() error path" failed to apply to 6.6-stable tree To: lgs201920130244@gmail.com,kuba@kernel.org,longli@microsoft.com Cc: From: Date: Mon, 30 Mar 2026 11:38:42 +0200 Message-ID: <2026033042-retriever-acclaim-5e38@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.6-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.6.y git checkout FETCH_HEAD git cherry-pick -x c4ea7d8907cf72b259bf70bd8c2e791e1c4ff70f # git commit -s git send-email --to '' --in-reply-to '2026033042-retriever-acclaim-5e38@gregkh' --subject-prefix 'PATCH 6.6.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);