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 3DA292236E3; Mon, 20 Apr 2026 16:01:15 +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=1776700875; cv=none; b=iAUEdbPl31mZWVcC818j3alxgiFhJPJtzjF7+CygZcB9e/04WMkBKYzfTeKHEEgsJMd1ZrXCvRnZtPI6P1R4snRgQRIi4CHi341hR6v6qQFr4Od+FlAvw/6f+qztM+4YLwSdvyRAMpxR+SY62z2hmwntAvKaT2HCs81uXtlehLY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700875; c=relaxed/simple; bh=R2ueKKP4bggTDh65j9bUERkIchap9OkGMjRvSpzMUa4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kmNhWRQ+WF1AtvvNjUgtuIBtDqoBlK1njqpvzBvJDx7GwI35iz3joWDguNcSJaD3RqGCetEYK3ce87vU5OfkEaLo9jxyPVpK+Y9Rm8zWwhs/trz1qkX8oIjRk0FjsjH96mSqN/mHZFAbHKwSRtsqa7tI6MdWQP7WqeMenWpA5uU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EzCcLXxN; 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="EzCcLXxN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C67C8C19425; Mon, 20 Apr 2026 16:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776700875; bh=R2ueKKP4bggTDh65j9bUERkIchap9OkGMjRvSpzMUa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EzCcLXxNqVD32OFOnVY91aWG1bIr0/tP3BE6NXQG1JvQpqdsRRIw1KxerfwgANDeS U29Nn4zhv8DBPWoBhKI/ZmQ1kPpa7xbVq9iRXpq79q9S1/sfEJPUQ9f+phX2JnWyCg utQfhaiPBtYgE2yLIyMeN2pdiLGPv8BaWun9Z6ts= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kotlyarov Mihail , Florian Westphal , Steffen Klassert , Sasha Levin Subject: [PATCH 6.18 093/198] xfrm: fix refcount leak in xfrm_migrate_policy_find Date: Mon, 20 Apr 2026 17:41:12 +0200 Message-ID: <20260420153938.954515879@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153935.605963767@linuxfoundation.org> References: <20260420153935.605963767@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kotlyarov Mihail [ Upstream commit 83317cce60a032c49480dcdabe146435bd689d03 ] syzkaller reported a memory leak in xfrm_policy_alloc: BUG: memory leak unreferenced object 0xffff888114d79000 (size 1024): comm "syz.1.17", pid 931 ... xfrm_policy_alloc+0xb3/0x4b0 net/xfrm/xfrm_policy.c:432 The root cause is a double call to xfrm_pol_hold_rcu() in xfrm_migrate_policy_find(). The lookup function already returns a policy with held reference, making the second call redundant. Remove the redundant xfrm_pol_hold_rcu() call to fix the refcount imbalance and prevent the memory leak. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: 563d5ca93e88 ("xfrm: switch migrate to xfrm_policy_lookup_bytype") Signed-off-by: Kotlyarov Mihail Reviewed-by: Florian Westphal Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_policy.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 4526c9078b136..29c94ee0ceb25 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -4528,9 +4528,6 @@ static struct xfrm_policy *xfrm_migrate_policy_find(const struct xfrm_selector * pol = xfrm_policy_lookup_bytype(net, type, &fl, sel->family, dir, if_id); if (IS_ERR_OR_NULL(pol)) goto out_unlock; - - if (!xfrm_pol_hold_rcu(pol)) - pol = NULL; out_unlock: rcu_read_unlock(); return pol; -- 2.53.0