All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Su Yue <l@damenly.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>,
	linux-bcachefs@vger.kernel.org
Subject: Re: [BUG] general protection fault, probably for non-canonical address 0x280766500040001: 0000 [#1] PREEMPT SMP PTI
Date: Wed, 17 Jan 2024 08:07:38 -0500	[thread overview]
Message-ID: <ZafRGgsW9Z7oORtV@bfoster> (raw)
In-Reply-To: <bk9k60zw.fsf@damenly.org>

On Wed, Jan 17, 2024 at 12:20:55PM +0800, Su Yue wrote:
> 
> On Tue 16 Jan 2024 at 12:33, Kent Overstreet <kent.overstreet@linux.dev>
> wrote:
> 
> > On Tue, Jan 16, 2024 at 12:24:48PM -0500, Brian Foster wrote:
> > > On Tue, Jan 16, 2024 at 12:03:09PM -0500, Kent Overstreet wrote:
> > > > On Tue, Jan 16, 2024 at 10:33:08AM -0500, Brian Foster wrote:
> > > > > Hi Kent,
> > > > >
> > > > > JFYI, I'm seeing the following splat pretty reliably via > >
> > > generic/361 on
> > > > > an 80xcpu test box. The CI doesn't seem to produce this > >
> > > failure for
> > > > > whatever reason. This bisects down to commit 023f9ac9f70f > >
> > > ("bcachefs:
> > > > > Delete dio read alignment check"), before which the test > >
> > > still fails but
> > > > > the kernel doesn't explode.
> > > > >
> > > > > Brian
> > > > >
> > > >
> > > > Can you test the following?
> > > >
> > > 
> > > Still blows up... repeated a couple times to be sure.
> > 
> > That sounds like a driver bug then - what driver?
> 
> 
> I think it's not a drive bug. It's related to bcachefs block_size.
> I can reproduce it by running generic/361 with block_size 4096.
> 
> The test devices are normal qemu disks backing by files in host.
> The bug disappears after hanging mkfs block_size to 512.
> 

Hi Su,

Yes, I think this is the issue as block_bytes(c) is 4k in my test.
Thanks for testing/confirming.

The immediate reason for the crash appears to be bio_copy_data_iter()
going off the rails trying to copy a larger source bio into a smaller
destination bio with seemingly inconsistent size/bvec.

The broader context is we start with a sub-block sized read, so e.g. I
see a request for 1024 bytes at offset 4096. This results in a bio with
bi_size == 4096, however, because right after the alignment check that
was removed we do this:

	ret = min_t(loff_t, iter->count,
		    max_t(loff_t, 0, i_size_read(&inode->v) - offset));
	...
	shorten = iov_iter_count(iter) - round_up(ret, block_bytes(c));
	iter->count -= shorten;

... which appears to underflow the iter count and is presumably fixed up
somewhere to cap at the block size. I'm assuming this ends up in a
situation where an internally inconsistent iov_iter leads to a similarly
broken bvec_iter on the bio, or otherwise this gets further confused
when creating the bounce bio, but I haven't traced to that level of
detail.

In any event, we end up in bio_copy_data_iter() with a destination bio
of bi_size == 4k that only appears to have a single 1k sized bvec. The
first 1k copies as expected, but this doesn't reduce bi_size to zero and
so the iteration just continues to advance the bio vec index until it
finds some garbage data it can infer as a non-zero bv_len bvec to copy
into.

Brian

> --
> Su
> 


      reply	other threads:[~2024-01-17 13:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 15:33 [BUG] general protection fault, probably for non-canonical address 0x280766500040001: 0000 [#1] PREEMPT SMP PTI Brian Foster
2024-01-16 16:37 ` Kent Overstreet
2024-01-16 17:03 ` Kent Overstreet
2024-01-16 17:24   ` Brian Foster
2024-01-16 17:33     ` Kent Overstreet
2024-01-17  4:20       ` Su Yue
2024-01-17 13:07         ` Brian Foster [this message]

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=ZafRGgsW9Z7oORtV@bfoster \
    --to=bfoster@redhat.com \
    --cc=kent.overstreet@linux.dev \
    --cc=l@damenly.org \
    --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.