All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] xfs: ubsan fixes
@ 2017-11-28 17:39 Darrick J. Wong
  2017-11-28 17:40 ` [PATCH 2/3] xfs: remove unused parameter from xfs_writepage_map Darrick J. Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Darrick J. Wong @ 2017-11-28 17:39 UTC (permalink / raw)
  To: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Fix some complaints from the UBSAN about signed integer addition overflows.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 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 a3eeaba..b0cccf8 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -399,7 +399,7 @@ xfs_map_blocks(
 	       (ip->i_df.if_flags & XFS_IFEXTENTS));
 	ASSERT(offset <= mp->m_super->s_maxbytes);
 
-	if (offset + count > mp->m_super->s_maxbytes)
+	if ((xfs_ufsize_t)offset + count > mp->m_super->s_maxbytes)
 		count = mp->m_super->s_maxbytes - offset;
 	end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
 	offset_fsb = XFS_B_TO_FSBT(mp, offset);
@@ -1265,7 +1265,7 @@ xfs_map_trim_size(
 	if (mapping_size > size)
 		mapping_size = size;
 	if (offset < i_size_read(inode) &&
-	    offset + mapping_size >= i_size_read(inode)) {
+	    (xfs_ufsize_t)offset + mapping_size >= i_size_read(inode)) {
 		/* limit mapping to block that spans EOF */
 		mapping_size = roundup_64(i_size_read(inode) - offset,
 					  i_blocksize(inode));
@@ -1312,7 +1312,7 @@ xfs_get_blocks(
 	lockmode = xfs_ilock_data_map_shared(ip);
 
 	ASSERT(offset <= 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 = mp->m_super->s_maxbytes - offset;
 	end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size);
 	offset_fsb = XFS_B_TO_FSBT(mp, offset);


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-12-14 16:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 17:39 [PATCH 1/3] xfs: ubsan fixes Darrick J. Wong
2017-11-28 17:40 ` [PATCH 2/3] xfs: remove unused parameter from xfs_writepage_map Darrick J. Wong
2017-11-30 13:47   ` Brian Foster
2017-11-28 17:40 ` [PATCH 3/3] xfs: scrub inode mode properly Darrick J. Wong
2017-11-30 13:47   ` Brian Foster
2017-11-30 13:47 ` [PATCH 1/3] xfs: ubsan fixes Brian Foster
2017-12-14 16:33 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.