From: kmpfqgdwxucqz9@gmail.com
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
KernelKraze <admin@mail.free-proletariat.dpdns.org>
Subject: Re: [PATCH 1/1] btrfs: add integer overflow protection to flush_dir_items_batch allocation
Date: Wed, 30 Jul 2025 15:58:18 +0900 [thread overview]
Message-ID: <20250730065818.149092-1-admin@mail.free-proletariat.dpdns.org> (raw)
In-Reply-To: <53686e91-5822-4137-9f79-e4f4d98ff6fb@wdc.com>
From: KernelKraze <admin@mail.free-proletariat.dpdns.org>
Hi Johannes,
Thanks for the review.
On 7/30/25 6:35 AM, Johannes Thumshirn wrote:
> Where does this number come from?
It's from log_delayed_insertion_items() at line 6111:
/* 195 (4095 bytes of keys and sizes) fits in a single 4K page. */
const int max_batch_size = 195;
I reused this limit for consistency across btrfs batch operations.
> Wouldn't kcalloc() or kmalloc_array() be the better choice here?
> kcalloc() calls kmalloc_array() which in term does overflow checking.
Good point. The issue is we're allocating a mixed buffer:
[u32 sizes array][struct btrfs_key keys array]
kmalloc_array() handles single-type arrays, but we need:
- ins_sizes = (u32 *)ins_data
- ins_keys = (struct btrfs_key *)(ins_data + sizes_size)
Two options:
1. Keep current approach with manual overflow checks
2. Split into separate kmalloc_array() calls (potential cache miss cost)
Which would you prefer? I'm happy to rework it either way.
Thanks,
KernelKraze
next prev parent reply other threads:[~2025-07-30 6:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 4:43 [PATCH 0/1] btrfs: strengthen integer overflow protection in batch allocation kmpfqgdwxucqz9
2025-07-30 4:43 ` [PATCH 1/1] btrfs: add integer overflow protection to flush_dir_items_batch allocation kmpfqgdwxucqz9
2025-07-30 6:35 ` Johannes Thumshirn
2025-07-30 6:58 ` kmpfqgdwxucqz9 [this message]
2025-07-30 7:06 ` Qu Wenruo
2025-07-30 7:20 ` [PATCH 1/1] btrfs: add integer overflow protection to flush_dir_items_batch allocation - WITHDRAWN kmpfqgdwxucqz9
2025-07-30 10:20 ` [PATCH 1/1] btrfs: add integer overflow protection to flush_dir_items_batch allocation Filipe Manana
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=20250730065818.149092-1-admin@mail.free-proletariat.dpdns.org \
--to=kmpfqgdwxucqz9@gmail.com \
--cc=Johannes.Thumshirn@wdc.com \
--cc=admin@mail.free-proletariat.dpdns.org \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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 NNTP newsgroup(s).