Linux-XFS Archive mirror
 help / color / mirror / Atom feed
From: Andrey Shumilin <shum.sdl@nppct.ru>
To: Chandan Babu R <chandan.babu@oracle.com>
Cc: Andrey Shumilin <shum.sdl@nppct.ru>,
	"Darrick J. Wong" <djwong@kernel.org>,
	Dave Chinner <dchinner@redhat.com>,
	linux-xfs@vger.kernel.org,
	linux-kernel@vger.kernel.org (open list),
	lvc-project@linuxtesting.org, khoroshilov@ispras.ru,
	ykarpov@ispras.ru, vmerzlyakov@ispras.ru, vefanov@ispras.ru
Subject: [PATCH 2/2] xfs_refcount: Preventing integer overflow
Date: Sat, 23 Mar 2024 09:26:03 +0300	[thread overview]
Message-ID: <20240323062603.665572-1-shum.sdl@nppct.ru> (raw)

Multiplying variables can overflow the "overhead" variable.
To fix this, the variable type has been increased.
Next, a subtraction operation occurs with it,
but before that it is checked.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Andrey Shumilin <shum.sdl@nppct.ru>
---
 fs/xfs/libxfs/xfs_refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 511c912d515c..cbf07552eaff 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1070,7 +1070,7 @@ static bool
 xfs_refcount_still_have_space(
 	struct xfs_btree_cur		*cur)
 {
-	unsigned long			overhead;
+	unsigned long long		overhead;
 
 	/*
 	 * Worst case estimate: full splits of the free space and rmap btrees
-- 
2.30.2


             reply	other threads:[~2024-03-23  6:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23  6:26 Andrey Shumilin [this message]
2024-03-23 18:45 ` [PATCH 2/2] xfs_refcount: Preventing integer overflow Darrick J. Wong

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=20240323062603.665572-1-shum.sdl@nppct.ru \
    --to=shum.sdl@nppct.ru \
    --cc=chandan.babu@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=khoroshilov@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=vefanov@ispras.ru \
    --cc=vmerzlyakov@ispras.ru \
    --cc=ykarpov@ispras.ru \
    /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).