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 88EE81D014A; Wed, 2 Oct 2024 14:48:18 +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=1727880499; cv=none; b=GcfXtE38WMB+92Ja9rRcypMS9zD7JlbDUahNRYRMjMuTBL4z0mcyOw+qUz9N/UderpvUl742kOOIL+KEO7z2hMdxIKOGaq9PCrD2NBrQL+OUuhmydiffLxPnW3/dEQbKSKZh00OGxKL8Xw+NnQnvYx0imyZJJtqUU0QQEim+p6U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880499; c=relaxed/simple; bh=p1Vpmpg1qdqKZ5Ui3v7O+qVvQLiRyuxDpHyJG48GEOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ms0HaqrXUyEz1UIbDxETik+/29AqLcpzoi9cQWN45zcby30xy3xW5QlB2JxGw6ZyCBufE7RQWTNATb3xGr1JpfzUs3aeJDfDPLub4Z8MfHsJZpV6nkbxW/GYfdP8cD3rwN4WI7j46aMkS7GFerx59vnR+0cGjbgRw0k1LUtL32M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kZAM9SpW; 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="kZAM9SpW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7D56C4CEC2; Wed, 2 Oct 2024 14:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727880498; bh=p1Vpmpg1qdqKZ5Ui3v7O+qVvQLiRyuxDpHyJG48GEOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZAM9SpWIdOZ0kuVxbH3tIIe8eMZ65Q7uyPo7k2kKlwu4pq/1z6qEVaixF3u8Csnh CJHAFIZuMWmud6PEeIjx0Aux0Jb8o6qdbSM7X24gk5ZeY5op/VmlMYhXxwDcKd89WI ZkoUaus4b8JKc1GVoTdePylk2nkTsdneYuKsOXug= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Gafert , Max Ferger , Van Giang Nguyen , Daniel Jordan , Herbert Xu Subject: [PATCH 6.6 480/538] padata: use integer wrap around to prevent deadlock on seq_nr overflow Date: Wed, 2 Oct 2024 15:01:59 +0200 Message-ID: <20241002125811.391667434@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125751.964700919@linuxfoundation.org> References: <20241002125751.964700919@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: VanGiang Nguyen commit 9a22b2812393d93d84358a760c347c21939029a6 upstream. When submitting more than 2^32 padata objects to padata_do_serial, the current sorting implementation incorrectly sorts padata objects with overflowed seq_nr, causing them to be placed before existing objects in the reorder list. This leads to a deadlock in the serialization process as padata_find_next cannot match padata->seq_nr and pd->processed because the padata instance with overflowed seq_nr will be selected next. To fix this, we use an unsigned integer wrap around to correctly sort padata objects in scenarios with integer overflow. Fixes: bfde23ce200e ("padata: unbind parallel jobs from specific CPUs") Cc: Co-developed-by: Christian Gafert Signed-off-by: Christian Gafert Co-developed-by: Max Ferger Signed-off-by: Max Ferger Signed-off-by: Van Giang Nguyen Acked-by: Daniel Jordan 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 @@ -404,7 +404,8 @@ void padata_do_serial(struct padata_priv /* Sort in ascending order of sequence number. */ list_for_each_prev(pos, &reorder->list) { cur = list_entry(pos, struct padata_priv, list); - if (cur->seq_nr < padata->seq_nr) + /* Compare by difference to consider integer wrap around */ + if ((signed int)(cur->seq_nr - padata->seq_nr) < 0) break; } list_add(&padata->list, pos);