All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Daeho Jeong <daeho43@gmail.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: chao@kernel.org, Daeho Jeong <daehojeong@google.com>,
	stable@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid underflow in get_available_block_count()
Date: Tue, 1 Dec 2026 16:20:14 +0800	[thread overview]
Message-ID: <d01c1a48-fa03-406a-88d0-207387b98993@kernel.org> (raw)
In-Reply-To: <20261114011734.3806377-1-daeho43@gmail.com>

On 11/14/26 09:17, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> get_available_block_count() subtracts current_reserved_blocks,
> alias_reserved_blocks and root_reserved_blocks from user_block_count
> without checking the result. Only unusable_block_count is handled so
> that the result does not go below 0.
> 
> f2fs_ioc_reserve_dev_alias() checks the free space with the root
> reserved blocks allowed when root calls it, so alias_reserved_blocks can
> overlap with the root reserved blocks until the reservation is turned
> into valid blocks. For example, with
> 
>   user_block_count = 1000, root_reserved_blocks = 100, valid blocks = 30
> 
> reserving an alias device of 950 blocks passes the check, since
> 30 + 950 <= 1000, and sets alias_reserved_blocks to 950. Then, for a
> user who cannot use the root reserved blocks, the available block count
> is 1000 - 950 - 100, which wraps around to a huge value, so the check in
> inc_valid_block_count() does not stop such a user until the reservation
> is done.
> 
> current_reserved_blocks can make it wrap in the same way, for root as
> well, when reserved_blocks is written through sysfs in the meantime,
> since it is set without considering alias_reserved_blocks.
> 
> Sum up all the reservations and return 0 if they do not fit in
> user_block_count, as was done for unusable_block_count only.
> 
> Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing")
> Cc: stable@vger.kernel.org
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Daeho Jeong <daeho43@gmail.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>, stable@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid underflow in get_available_block_count()
Date: Tue, 1 Dec 2026 16:20:14 +0800	[thread overview]
Message-ID: <d01c1a48-fa03-406a-88d0-207387b98993@kernel.org> (raw)
In-Reply-To: <20261114011734.3806377-1-daeho43@gmail.com>

On 11/14/26 09:17, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> get_available_block_count() subtracts current_reserved_blocks,
> alias_reserved_blocks and root_reserved_blocks from user_block_count
> without checking the result. Only unusable_block_count is handled so
> that the result does not go below 0.
> 
> f2fs_ioc_reserve_dev_alias() checks the free space with the root
> reserved blocks allowed when root calls it, so alias_reserved_blocks can
> overlap with the root reserved blocks until the reservation is turned
> into valid blocks. For example, with
> 
>   user_block_count = 1000, root_reserved_blocks = 100, valid blocks = 30
> 
> reserving an alias device of 950 blocks passes the check, since
> 30 + 950 <= 1000, and sets alias_reserved_blocks to 950. Then, for a
> user who cannot use the root reserved blocks, the available block count
> is 1000 - 950 - 100, which wraps around to a huge value, so the check in
> inc_valid_block_count() does not stop such a user until the reservation
> is done.
> 
> current_reserved_blocks can make it wrap in the same way, for root as
> well, when reserved_blocks is written through sysfs in the meantime,
> since it is set without considering alias_reserved_blocks.
> 
> Sum up all the reservations and return 0 if they do not fit in
> user_block_count, as was done for unusable_block_count only.
> 
> Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing")
> Cc: stable@vger.kernel.org
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2026-12-01  8:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  1:17 [f2fs-dev] [PATCH] f2fs: avoid underflow in get_available_block_count() Daeho Jeong
2026-11-14  1:17 ` Daeho Jeong
2026-12-01  8:20 ` Chao Yu [this message]
2026-12-01  8:20   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2026-12-03 23:20 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
2026-12-03 23:20   ` patchwork-bot+f2fs

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=d01c1a48-fa03-406a-88d0-207387b98993@kernel.org \
    --to=chao@kernel.org \
    --cc=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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 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.