From: Peter Zijlstra <peterz@infradead.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Jeff Layton <jlayton@kernel.org>,
Ilya Dryomov <idryomov@gmail.com>,
ceph-devel@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Matthew Wilcox <willy@infradead.org>,
clang-built-linux <llvm@lists.linux.dev>
Subject: Re: Simplify load_unaligned_zeropad() (was Re: [GIT PULL] Ceph updates for 5.20-rc1)
Date: Wed, 17 Aug 2022 09:45:45 +0200 [thread overview]
Message-ID: <YvycqWVs5JbBR1D+@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <CAHk-=wjZ0oC0__-kLX51jRwo4XgAQ9xJ=OeT5_=fiLxmDexFZw@mail.gmail.com>
On Tue, Aug 16, 2022 at 10:57:45AM -0700, Linus Torvalds wrote:
> > > + if (insn_decode(&insn, (void *) regs->ip, len, INSN_MODE_KERN))
> > > + return false;
> >
> > We have insn_decode_kernel() for exactly this (very) common case.
>
> I did that originally, and then I undid it in disgust, because that
> interface is too simple.
>
> In particular, it just uses MAX_INSN_SIZE blindly. Which I didn't want
> to do when I actually had the instruction size.
>
> Yes, yes, I also check the decode size after-the-fact, but I didn't
> want the decoder to even look at the invalid bytes.
>
> This exception case is about the data being at the end of the page, I
> wanted the fixup to be aware of code being at the end of a page too.
I don't want to argue this point too much; but I will anyway :-)
IMO if the decoder ends up out of bounds its a decoder bug either way
around. That is, we *know* there is a full instruction at the given IP
because we got into this exception path.
( it would be possible to add further constraints on trapnr )
Irrespective of the length constraint given to the decoder, it should
not decode/access things past this instruction (without being careful
about it).
Anyway, I'm fine with the patch as you have it.
prev parent reply other threads:[~2022-08-17 7:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-14 21:14 Simplify load_unaligned_zeropad() (was Re: [GIT PULL] Ceph updates for 5.20-rc1) Linus Torvalds
2022-08-14 22:54 ` Kirill A. Shutemov
2022-08-14 22:59 ` Linus Torvalds
2022-08-15 3:43 ` Linus Torvalds
2022-08-15 4:12 ` Kirill A. Shutemov
2022-08-24 19:02 ` Dave Hansen
2022-08-15 8:26 ` Mike Rapoport
2022-08-15 7:17 ` Peter Zijlstra
2022-08-15 15:58 ` Linus Torvalds
2022-08-15 17:53 ` Peter Zijlstra
2022-08-15 20:09 ` Peter Zijlstra
2022-08-15 22:49 ` Linus Torvalds
2022-08-16 8:02 ` Peter Zijlstra
2022-08-16 17:57 ` Linus Torvalds
2022-08-17 7:45 ` Peter Zijlstra [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=YvycqWVs5JbBR1D+@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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