[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wg3prAnhWZetJvwZdugn7A7CpP4ruz1tdewha=8ZY8AJw@mail.gmail.com>
Date: Tue, 12 Oct 2021 10:58:46 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Catalin Marinas <catalin.marinas@....com>
Cc: Al Viro <viro@...iv.linux.org.uk>,
Andreas Gruenbacher <agruenba@...hat.com>,
Christoph Hellwig <hch@...radead.org>,
"Darrick J. Wong" <djwong@...nel.org>, Jan Kara <jack@...e.cz>,
Matthew Wilcox <willy@...radead.org>,
cluster-devel <cluster-devel@...hat.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"ocfs2-devel@....oracle.com" <ocfs2-devel@....oracle.com>,
Josef Bacik <josef@...icpanda.com>,
Will Deacon <will@...nel.org>
Subject: Re: [RFC][arm64] possible infinite loop in btrfs search_ioctl()
On Tue, Oct 12, 2021 at 10:27 AM Catalin Marinas
<catalin.marinas@....com> wrote:
>
> Apart from fault_in_pages_*(), there's also fault_in_user_writeable()
> called from the futex code which uses the GUP mechanism as the write
> would be destructive. It looks like it could potentially trigger the
> same infinite loop on -EFAULT.
Hmm.
I think the reason we do fault_in_user_writeable() using GUP is that
(a) we can avoid the page fault overhead
(b) we don't have any good "atomic_inc_user()" interface or similar
that could do a write with a zero increment or something like that.
We do have that "arch_futex_atomic_op_inuser()" thing, of course. It's
all kinds of crazy, but we *could* do
arch_futex_atomic_op_inuser(FUTEX_OP_ADD, 0, &dummy, uaddr);
instead of doing the fault_in_user_writeable().
That might be a good idea anyway. I dunno.
But I agree other options exist:
> I wonder whether we should actually just disable tag checking around the
> problematic accesses. What these callers seem to have in common is using
> pagefault_disable/enable(). We could abuse this to disable tag checking
> or maybe in_atomic() when handling the exception to lazily disable such
> faults temporarily.
Hmm. That would work for MTE, but possibly be very inconvenient for
other situations.
> A more invasive change would be to return a different error for such
> faults like -EACCESS and treat them differently in the caller.
That's _really_ hard for things like "copy_to_user()", that isn't a
single operation, and is supposed to return the bytes left.
Adding another error return would be nasty.
We've had hacks like "squirrel away the actual error code in the task
structure", but that tends to be unmaintainable because we have
interrupts (and NMI's) doing their own possibly nested atomics, so
even disabling preemption won't actually fix some of the nesting
issues.
All of these things make me think that the proper fix ends up being to
make sure that our "fault_in_xyz()" functions simply should always
handle all faults.
Another option may be to teach the GUP code to actually check
architecture-specific sub-page ranges.
Linus
Powered by blists - more mailing lists