[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <vukrlmb4kbpcol6rtest3tsw4y6obopbrwi5hcb5iwzogsopgt@sokysuzxvehi>
Date: Tue, 6 May 2025 12:18:49 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Sean Christopherson <seanjc@...gle.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org, kys@...rosoft.com, haiyangz@...rosoft.com,
wei.liu@...nel.org, decui@...rosoft.com, tglx@...utronix.de, mingo@...hat.com,
bp@...en8.de, dave.hansen@...ux.intel.com, pbonzini@...hat.com,
ardb@...nel.org, kees@...nel.org, Arnd Bergmann <arnd@...db.de>,
gregkh@...uxfoundation.org, linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, linux-efi@...r.kernel.org, samitolvanen@...gle.com,
ojeda@...nel.org, xin@...or.com
Subject: Re: [PATCH v2 00/13] objtool: Detect and warn about indirect calls
in __nocfi functions
On Tue, May 06, 2025 at 03:32:34PM +0200, Peter Zijlstra wrote:
> On Tue, May 06, 2025 at 09:31:00AM +0200, Peter Zijlstra wrote:
> > On Sat, May 03, 2025 at 11:28:37AM -0700, Josh Poimboeuf wrote:
> > > Can we just adjust the stack in the alternative?
> > >
> > > ALTERNATIVE "add $64 %rsp", __stringify(ERETS), X86_FEATURE_FRED
> >
> > Yes, that should work.
>
> Nope, it needs to be "mov %rbp, %rsp". Because that is the actual rsp
> value after ERETS-to-self.
>
> > But I wanted to have a poke at objtool, so it
> > will properly complain about the mistake first.
>
> So a metric ton of fail here :/
>
> The biggest problem is the UNWIND_HINT_RESTORE right after the
> alternative. This ensures that objtool thinks all paths through the
> alternative end up with the same stack. And hence won't actually
> complain.
Right, that's what the unwind hints are made for, it's up to the human
to get it right.
> Second being of course, that in order to get IRET and co correct, we'd
> need far more of an emulator.
At least finding RSP should be pretty easy, it's at a known location on
the stack. We already have an ORC type for doing that, but that would
again require an unwind hint, unless we make objtool smart enough to
know that. But then the ORC would be inconsistent between the two
alternative paths.
> Also, it actually chokes on this variant, and I've not yet figured out
> why. Whatever state should be created by that mov, the restore hint
> should wipe it all. But still the ORC generation bails with unknown base
> reg -1.
Weird, I'm not seeing that.
--
Josh
Powered by blists - more mailing lists