Re: Stack corruption in bch2_nocow_write

From: Daniel J Blueman
Date: Sat Dec 30 2023 - 03:35:04 EST


On Sat, 30 Dec 2023 at 02:54, Kent Overstreet <kent.overstreet@xxxxxxxxx> wrote:
>
> On Fri, Dec 29, 2023 at 07:43:13PM +0800, Daniel J Blueman wrote:
> > Hi Kent et al,
> >
> > On Linux 6.7-rc7 from bcachefs master SHA f3608cbdfd built with UBSAN
> > [1], with a crafted workload [2] I'm able to trigger stack corruption
> > in bch2_nocow_write [3].
> >
> > Let me know if you can't reproduce it and I'll check reproducibility
> > on another platform, and let me know for any patch testing.
>
> this should be fixed in the testing branch:
>
> commit ab35f724070ccdaa31f6376a1890473e7d031ed0
> Author: Kent Overstreet <kent.overstreet@xxxxxxxxx>
> Date: Fri Dec 29 13:54:00 2023 -0500
>
> bcachefs: fix nocow write path when writing to multiple extents
>
> Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
>
> diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c
> index c5961bac19f0..7c5963cd0b85 100644
> --- a/fs/bcachefs/io_write.c
> +++ b/fs/bcachefs/io_write.c
> @@ -1316,6 +1316,7 @@ static void bch2_nocow_write(struct bch_write_op *op)
> closure_get(&op->cl);
> bch2_submit_wbio_replicas(to_wbio(bio), c, BCH_DATA_user,
> op->insert_keys.top, true);
> + nr_buckets = 0;
>
> bch2_keylist_push(&op->insert_keys);
> if (op->flags & BCH_WRITE_DONE)

Thanks for the quick update, Kent.

With this change and a few runs of the reproducer, I still hit this
stack corruption with the same backtrace.

Let me know for any further testing,
Dan
--
Daniel J Blueman