public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_repair: resolve Coverity OVERFLOW_BEFORE_WIDEN
@ 2016-06-23 17:07 Bill O'Donnell
  2016-06-23 17:35 ` Eric Sandeen
  0 siblings, 1 reply; 2+ messages in thread
From: Bill O'Donnell @ 2016-06-23 17:07 UTC (permalink / raw)
  To: xfs

Coverity complains that when multiplying two 32 bit values that
eventually will be stored in a 64 bit value that it's possible
the math could overflow unless one of the values being multiplied
is type cast to the proper size.

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
 repair/sb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/repair/sb.c b/repair/sb.c
index 3965953..8d4843c 100644
--- a/repair/sb.c
+++ b/repair/sb.c
@@ -230,7 +230,7 @@ find_secondary_sb(xfs_sb_t *rsb)
 	do_warn(_("\nattempting to find secondary superblock...\n"));
 
 	if (verify_sb_blocksize(rsb) == 0) {
-		skip = rsb->sb_agblocks * rsb->sb_blocksize;
+		skip = (__uint64_t)rsb->sb_agblocks * rsb->sb_blocksize;
 		if (skip >= XFS_AG_MIN_BYTES && skip <= XFS_AG_MAX_BYTES)
 			retval = __find_secondary_sb(rsb, skip, skip);
 	}
-- 
2.7.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] xfs_repair: resolve Coverity OVERFLOW_BEFORE_WIDEN
  2016-06-23 17:07 [PATCH] xfs_repair: resolve Coverity OVERFLOW_BEFORE_WIDEN Bill O'Donnell
@ 2016-06-23 17:35 ` Eric Sandeen
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2016-06-23 17:35 UTC (permalink / raw)
  To: xfs



On 6/23/16 12:07 PM, Bill O'Donnell wrote:
> Coverity complains that when multiplying two 32 bit values that
> eventually will be stored in a 64 bit value that it's possible
> the math could overflow unless one of the values being multiplied
> is type cast to the proper size.
> 
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>

Makes sense.  Given that this is repair, and either value could
be larger than expected, we need the skip value to be accurate.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  repair/sb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/repair/sb.c b/repair/sb.c
> index 3965953..8d4843c 100644
> --- a/repair/sb.c
> +++ b/repair/sb.c
> @@ -230,7 +230,7 @@ find_secondary_sb(xfs_sb_t *rsb)
>  	do_warn(_("\nattempting to find secondary superblock...\n"));
>  
>  	if (verify_sb_blocksize(rsb) == 0) {
> -		skip = rsb->sb_agblocks * rsb->sb_blocksize;
> +		skip = (__uint64_t)rsb->sb_agblocks * rsb->sb_blocksize;
>  		if (skip >= XFS_AG_MIN_BYTES && skip <= XFS_AG_MAX_BYTES)
>  			retval = __find_secondary_sb(rsb, skip, skip);
>  	}
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2016-06-23 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-23 17:07 [PATCH] xfs_repair: resolve Coverity OVERFLOW_BEFORE_WIDEN Bill O'Donnell
2016-06-23 17:35 ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox