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 6364A2566; Tue, 27 May 2025 17:54:48 +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=1748368488; cv=none; b=bYuZaKr2hClzZ3S5qX4kL1Qfz2PzRF9Ei800abQdt5VmTpjEps1mAvKI4FqQKeF70gr5hjIulrGnjrfRSh2RQaJ/I0hAyj1Ov8jJpdCL9D7gNutDtRW/ay0YHBkFCO1LU4nWQBbq6xh4llGxLBKciCYMHW+CpfV0qYGx88j2v0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748368488; c=relaxed/simple; bh=FRccjqWV12AHYh69/xr68opL1J8pedcwteuRbQSBdbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/Qxo8tOqanMYUuiUspLkNlgbiNiU8I+eILWNbkp1LEFy8vTvNwsTettK5X66pc4+/7BKu87dnGZtjiubbM9tsM+/v47a2EZeg1KpeUqARitarQbOKI5wkKHLZhRtK6xMOjdPUXk34ZXTrKNlnoIafnFDHWWHx+v9K3XDRxHtC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xDACAm3+; 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="xDACAm3+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D805C4CEE9; Tue, 27 May 2025 17:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748368487; bh=FRccjqWV12AHYh69/xr68opL1J8pedcwteuRbQSBdbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDACAm3+tJgIrCjryCxZJjHKhBNe35fe5oX8yn6RWMlniRWZSM6+zgYgn6ytSvvBw 55xOOf27C5mIs99oKj1k1GZ0ZtbsHRIPRvMij4zqjs5qvWUquze5fEaUBjvnxQjmzo 1aq7eJ4zGocU+l3TlF9c73152VMPYI+1nH1bM9GE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dominik Grzegorzek , Herbert Xu Subject: [PATCH 6.14 723/783] padata: do not leak refcount in reorder_work Date: Tue, 27 May 2025 18:28:40 +0200 Message-ID: <20250527162542.552782498@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250527162513.035720581@linuxfoundation.org> References: <20250527162513.035720581@linuxfoundation.org> User-Agent: quilt/0.68 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dominik Grzegorzek commit d6ebcde6d4ecf34f8495fb30516645db3aea8993 upstream. A recent patch that addressed a UAF introduced a reference count leak: the parallel_data refcount is incremented unconditionally, regardless of the return value of queue_work(). If the work item is already queued, the incremented refcount is never decremented. Fix this by checking the return value of queue_work() and decrementing the refcount when necessary. Resolves: Unreferenced object 0xffff9d9f421e3d80 (size 192): comm "cryptomgr_probe", pid 157, jiffies 4294694003 hex dump (first 32 bytes): 80 8b cf 41 9f 9d ff ff b8 97 e0 89 ff ff ff ff ...A............ d0 97 e0 89 ff ff ff ff 19 00 00 00 1f 88 23 00 ..............#. backtrace (crc 838fb36): __kmalloc_cache_noprof+0x284/0x320 padata_alloc_pd+0x20/0x1e0 padata_alloc_shell+0x3b/0xa0 0xffffffffc040a54d cryptomgr_probe+0x43/0xc0 kthread+0xf6/0x1f0 ret_from_fork+0x2f/0x50 ret_from_fork_asm+0x1a/0x30 Fixes: dd7d37ccf6b1 ("padata: avoid UAF for reorder_work") Cc: Signed-off-by: Dominik Grzegorzek Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- kernel/padata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/padata.c +++ b/kernel/padata.c @@ -358,7 +358,8 @@ static void padata_reorder(struct parall * To avoid UAF issue, add pd ref here, and put pd ref after reorder_work finish. */ padata_get_pd(pd); - queue_work(pinst->serial_wq, &pd->reorder_work); + if (!queue_work(pinst->serial_wq, &pd->reorder_work)) + padata_put_pd(pd); } }