From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0116.outbound.protection.outlook.com ([104.47.34.116]:58271 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032343AbeCAPc4 (ORCPT ); Thu, 1 Mar 2018 10:32:56 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: "Darrick J. Wong" , Sasha Levin Subject: [added to the 4.1 stable tree] xfs: ubsan fixes Date: Thu, 1 Mar 2018 15:25:32 +0000 Message-ID: <20180301152116.1486-276-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: "Darrick J. Wong" This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 22a6c83777ac7c17d6c63891beeeac24cf5da450 ] Fix some complaints from the UBSAN about signed integer addition overflows. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Sasha Levin --- fs/xfs/xfs_aops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index a56960dd1684..123ec87efac0 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -303,7 +303,7 @@ xfs_map_blocks( (ip->i_df.if_flags & XFS_IFEXTENTS)); ASSERT(offset <=3D mp->m_super->s_maxbytes); =20 - if (offset + count > mp->m_super->s_maxbytes) + if ((xfs_ufsize_t)offset + count > mp->m_super->s_maxbytes) count =3D mp->m_super->s_maxbytes - offset; end_fsb =3D XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); offset_fsb =3D XFS_B_TO_FSBT(mp, offset); @@ -1332,7 +1332,7 @@ xfs_map_trim_size( if (mapping_size > size) mapping_size =3D size; if (offset < i_size_read(inode) && - offset + mapping_size >=3D i_size_read(inode)) { + (xfs_ufsize_t)offset + mapping_size >=3D i_size_read(inode)) { /* limit mapping to block that spans EOF */ mapping_size =3D roundup_64(i_size_read(inode) - offset, 1 << inode->i_blkbits); @@ -1387,7 +1387,7 @@ __xfs_get_blocks( } =20 ASSERT(offset <=3D mp->m_super->s_maxbytes); - if (offset + size > mp->m_super->s_maxbytes) + if ((xfs_ufsize_t)offset + size > mp->m_super->s_maxbytes) size =3D mp->m_super->s_maxbytes - offset; end_fsb =3D XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size); offset_fsb =3D XFS_B_TO_FSBT(mp, offset); --=20 2.14.1