From: Alan Huang <mmpgouride@gmail.com>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-bcachefs@vger.kernel.org
Subject: Re: [PATCH] bcachefs: Fix use after free
Date: Tue, 11 Feb 2025 00:54:29 +0800 [thread overview]
Message-ID: <65D10A49-9A37-4844-9DE7-838205FF375C@gmail.com> (raw)
In-Reply-To: <glle55a36q4zzr72fa7a2n7gkp6z6xq26usmuxrojwlyctfxz7@mzhqlaumf64g>
On Feb 11, 2025, at 00:28, Kent Overstreet <kent.overstreet@linux.dev> wrote:
>
> On Mon, Feb 10, 2025 at 11:04:22AM +0800, Alan Huang wrote:
>> acc->k.data should be used with the lock hold:
>
> <snipped>
>
>>
>> Signed-off-by: Alan Huang <mmpgouride@gmail.com>
>
>
> Test this with lockdep (you know how to edit the lists of tests the CI
> runs, right?
The lockdep test group is in the tests lists.
Or you mean add tests in the lockdep group ?
>
> mark_lock usage is a giant mess, and calling percpu_down_read()
> recursively by accident will mostly work, until it doesn't.
>
>> ---
>> fs/bcachefs/disk_accounting.h | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/bcachefs/disk_accounting.h b/fs/bcachefs/disk_accounting.h
>> index 5360cbb3ec29..f4372cafea2e 100644
>> --- a/fs/bcachefs/disk_accounting.h
>> +++ b/fs/bcachefs/disk_accounting.h
>> @@ -210,11 +210,13 @@ static inline void bch2_accounting_mem_read_counters(struct bch_accounting_mem *
>> static inline void bch2_accounting_mem_read(struct bch_fs *c, struct bpos p,
>> u64 *v, unsigned nr)
>> {
>> + percpu_down_read(&c->mark_lock);
>> struct bch_accounting_mem *acc = &c->accounting;
>> unsigned idx = eytzinger0_find(acc->k.data, acc->k.nr, sizeof(acc->k.data[0]),
>> accounting_pos_cmp, &p);
>>
>> bch2_accounting_mem_read_counters(acc, idx, v, nr, false);
>> + percpu_up_read(&c->mark_lock);
>> }
>>
>> static inline struct bversion journal_pos_to_bversion(struct journal_res *res, unsigned offset)
>> --
>> 2.47.0
>>
next prev parent reply other threads:[~2025-02-10 16:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 3:04 [PATCH] bcachefs: Use uncompressed_size as the operand Alan Huang
2025-02-10 3:04 ` [PATCH] bcachefs: Fix use after free Alan Huang
2025-02-10 16:28 ` Kent Overstreet
2025-02-10 16:54 ` Alan Huang [this message]
2025-02-10 22:20 ` Kent Overstreet
2025-02-10 16:25 ` [PATCH] bcachefs: Use uncompressed_size as the operand Kent Overstreet
2025-02-10 17:02 ` Alan Huang
2025-02-10 22:02 ` Kent Overstreet
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=65D10A49-9A37-4844-9DE7-838205FF375C@gmail.com \
--to=mmpgouride@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@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.