All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_spaceman: fix potential overflowing expression in trim_f()
@ 2017-06-29 17:10 Bill O'Donnell
  2017-06-29 17:18 ` Darrick J. Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Bill O'Donnell @ 2017-06-29 17:10 UTC (permalink / raw)
  To: linux-xfs; +Cc: sandeen

Prevent the potential overflow in expression calculating offset
in trim_f(() by casting the first variable to off64_t (64bit signed).

Detected by CoverityScan, CID#1413771 Integer handling issues (OVERFLOW_BEFORE_WIDEN)

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

diff --git a/spaceman/trim.c b/spaceman/trim.c
index 872f68d3..6df9e6a9 100644
--- a/spaceman/trim.c
+++ b/spaceman/trim.c
@@ -77,7 +77,7 @@ trim_f(
 		length = cvtnum(file->geom.blocksize, file->geom.sectsize,
 				argv[optind + 1]);
 	} else if (agno) {
-		offset = agno * file->geom.agblocks * file->geom.blocksize;
+		offset = (off64_t)agno * file->geom.agblocks * file->geom.blocksize;
 		length = file->geom.agblocks * file->geom.blocksize;
 	} else {
 		offset = 0;
-- 
2.13.0


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

* Re: [PATCH] xfs_spaceman: fix potential overflowing expression in trim_f()
  2017-06-29 17:10 [PATCH] xfs_spaceman: fix potential overflowing expression in trim_f() Bill O'Donnell
@ 2017-06-29 17:18 ` Darrick J. Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-06-29 17:18 UTC (permalink / raw)
  To: Bill O'Donnell; +Cc: linux-xfs, sandeen

On Thu, Jun 29, 2017 at 12:10:05PM -0500, Bill O'Donnell wrote:
> Prevent the potential overflow in expression calculating offset
> in trim_f(() by casting the first variable to off64_t (64bit signed).
> 
> Detected by CoverityScan, CID#1413771 Integer handling issues (OVERFLOW_BEFORE_WIDEN)
> 
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  spaceman/trim.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/spaceman/trim.c b/spaceman/trim.c
> index 872f68d3..6df9e6a9 100644
> --- a/spaceman/trim.c
> +++ b/spaceman/trim.c
> @@ -77,7 +77,7 @@ trim_f(
>  		length = cvtnum(file->geom.blocksize, file->geom.sectsize,
>  				argv[optind + 1]);
>  	} else if (agno) {
> -		offset = agno * file->geom.agblocks * file->geom.blocksize;
> +		offset = (off64_t)agno * file->geom.agblocks * file->geom.blocksize;
>  		length = file->geom.agblocks * file->geom.blocksize;
>  	} else {
>  		offset = 0;
> -- 
> 2.13.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-06-29 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 17:10 [PATCH] xfs_spaceman: fix potential overflowing expression in trim_f() Bill O'Donnell
2017-06-29 17:18 ` Darrick J. Wong

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.