From: Dan Carpenter <dan.carpenter@linaro.org>
To: Dave Chinner <david@fromorbit.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
Chandan Babu R <chandan.babu@oracle.com>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] xfs: check for negatives in xfs_exchange_range_checks()
Date: Wed, 8 May 2024 12:20:22 +0300 [thread overview]
Message-ID: <20137ff5-76a7-4b3d-96d9-9c6c90cbb063@moroto.mountain> (raw)
In-Reply-To: <ZjrVaynGeygNaDtQ@dread.disaster.area>
On Wed, May 08, 2024 at 11:29:15AM +1000, Dave Chinner wrote:
> On Sat, May 04, 2024 at 02:27:36PM +0300, Dan Carpenter wrote:
> > The fxr->file1_offset and fxr->file2_offset variables come from the user
> > in xfs_ioc_exchange_range(). They are size loff_t which is an s64.
> > Check the they aren't negative.
> >
> > Fixes: 9a64d9b3109d ("xfs: introduce new file range exchange ioctl")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > From static analysis. Untested. Sorry!
> >
> > fs/xfs/xfs_exchrange.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c
> > index c8a655c92c92..3465e152d928 100644
> > --- a/fs/xfs/xfs_exchrange.c
> > +++ b/fs/xfs/xfs_exchrange.c
> > @@ -337,6 +337,9 @@ xfs_exchange_range_checks(
> > if (IS_SWAPFILE(inode1) || IS_SWAPFILE(inode2))
> > return -ETXTBSY;
> >
> > + if (fxr->file1_offset < 0 || fxr->file2_offset < 0)
> > + return -EINVAL;
>
> Aren't the operational offset/lengths already checked for underflow
> and overflow via xfs_exchange_range_verify_area()?
Ah right. Smatch complains in the middle of the two calls to
xfs_exchange_range_verify_area(). (It get's called in different places
depending on if the XFS_EXCHANGE_RANGE_TO_EOF flag is set).
regards,
dan carpenter
prev parent reply other threads:[~2024-05-08 9:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-04 11:27 [PATCH] xfs: check for negatives in xfs_exchange_range_checks() Dan Carpenter
2024-05-04 16:46 ` Markus Elfring
2024-05-07 6:06 ` Christoph Hellwig
2024-05-07 6:33 ` Dan Carpenter
2024-05-07 6:40 ` Christoph Hellwig
2024-05-07 23:36 ` Darrick J. Wong
2024-05-07 23:33 ` Darrick J. Wong
2024-05-08 1:29 ` Dave Chinner
2024-05-08 2:26 ` Darrick J. Wong
2024-05-08 9:20 ` Dan Carpenter [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=20137ff5-76a7-4b3d-96d9-9c6c90cbb063@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=chandan.babu@oracle.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).