From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Bill O'Donnell <billodo@redhat.com>
Cc: linux-xfs@vger.kernel.org, sandeen@sandeen.net
Subject: Re: [PATCH] xfs_spaceman: fix potential overflowing expression in trim_f()
Date: Thu, 29 Jun 2017 10:18:44 -0700 [thread overview]
Message-ID: <20170629171844.GG5874@birch.djwong.org> (raw)
In-Reply-To: <20170629171005.9886-1-billodo@redhat.com>
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
prev parent reply other threads:[~2017-06-29 17:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170629171844.GG5874@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=billodo@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).