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 87977311C2A for ; Thu, 19 Mar 2026 01:59:59 +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=1773885599; cv=none; b=lP1hgmM62rqCihtAaOH/BorV4DpVC219JlZJixUgHskE0SNIHWsFm0GJAuA/0Db8t4SPz39SnEOavgqQ9jXpk6MlUEdLkQaIcz8zGwA7mZaYC5RPsyzg+loJqYhrnn+CfoyJzg1TqC5xZVgz3+VLrXapLfk2s58u0nGJ6DN0Uyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773885599; c=relaxed/simple; bh=ON2Jr0MAF3+kDH2c2wltVSf2UU1Av5/++1dJzIh30Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sdWR6lsnw+1MhkmolFtd9spnTI5nL0J5iBU3jjqACMKSmC3ttaIWKvWkkwgS5E+Zl1jUfBDdCTagok9K2XSWmzAICqH72M7Z3evfTmQxMoAYPj1sS+1BlqGe7EeRAOdcu4OczQ9QmkuVdVFh4Iyfg+T7FupBNGQVrcVcibDimlM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZzoEKxR2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZzoEKxR2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D9B1C19421; Thu, 19 Mar 2026 01:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773885599; bh=ON2Jr0MAF3+kDH2c2wltVSf2UU1Av5/++1dJzIh30Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzoEKxR2nft3z9gP0mQevoEQEsLoq2qq/EaXo3B7v0hJ5Cm/VbaABUCZ3muB8Faas vqVUtyvEd4JHvCRcKmNFpJgjxbILTECua571sEe3ofb2bcApRZ0WNbMAMEwrtUeOlZ kBa0OrghNzKMWIunBQlURbLHoXGWOxId08tfzjLmnUNIP7RxjgpQq0XYpeEiwa7y23 n4HO75Iy2+yhJ6KN8ur/D5QBPw4O2Kl5a7HrHRMYfJ25r9MPXhMWS91TKijiq7NpxR U2NXrEC1wwcnBYakOEmf6WuA+4dlTOmIupttXqjx242GXfl64yDKed3e/Ran52A/ZG 6uV2B/vGrbgWQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Long Li , "Darrick J. Wong" , Carlos Maiolino , Sasha Levin Subject: [PATCH 6.12.y] xfs: fix integer overflow in bmap intent sort comparator Date: Wed, 18 Mar 2026 21:59:56 -0400 Message-ID: <20260319015956.1895520-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026031754-spearmint-genetics-93f2@gregkh> References: <2026031754-spearmint-genetics-93f2@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Long Li [ Upstream commit 362c490980867930a098b99f421268fbd7ca05fd ] xfs_bmap_update_diff_items() sorts bmap intents by inode number using a subtraction of two xfs_ino_t (uint64_t) values, with the result truncated to int. This is incorrect when two inode numbers differ by more than INT_MAX (2^31 - 1), which is entirely possible on large XFS filesystems. Fix this by replacing the subtraction with cmp_int(). Cc: # v4.9 Fixes: 9f3afb57d5f1 ("xfs: implement deferred bmbt map/unmap operations") Signed-off-by: Long Li Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino [ No cmp_int() ] Signed-off-by: Sasha Levin --- fs/xfs/xfs_bmap_item.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 35a8c1b8b3cb3..5f10a61c9b25a 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -237,7 +237,8 @@ xfs_bmap_update_diff_items( struct xfs_bmap_intent *ba = bi_entry(a); struct xfs_bmap_intent *bb = bi_entry(b); - return ba->bi_owner->i_ino - bb->bi_owner->i_ino; + return ((ba->bi_owner->i_ino > bb->bi_owner->i_ino) - + (ba->bi_owner->i_ino < bb->bi_owner->i_ino)); } /* Log bmap updates in the intent item. */ -- 2.51.0