[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c078d53409c3fbf6eac30966e8d68e097d7a6d5.camel@intel.com>
Date: Tue, 7 Oct 2025 19:53:25 +0000
From: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To: "Mehta, Sohil" <sohil.mehta@...el.com>, "tglx@...utronix.de"
<tglx@...utronix.de>, "mingo@...hat.com" <mingo@...hat.com>, "Hansen, Dave"
<dave.hansen@...el.com>, "dave.hansen@...ux.intel.com"
<dave.hansen@...ux.intel.com>, "bp@...en8.de" <bp@...en8.de>,
"x86@...nel.org" <x86@...nel.org>
CC: "corbet@....net" <corbet@....net>, "ardb@...nel.org" <ardb@...nel.org>,
"andrew.cooper3@...rix.com" <andrew.cooper3@...rix.com>,
"alexander.shishkin@...ux.intel.com" <alexander.shishkin@...ux.intel.com>,
"luto@...nel.org" <luto@...nel.org>, "david.laight.linux@...il.com"
<david.laight.linux@...il.com>, "jpoimboe@...nel.org" <jpoimboe@...nel.org>,
"Luck, Tony" <tony.luck@...el.com>, "linux-efi@...r.kernel.org"
<linux-efi@...r.kernel.org>, "kas@...nel.org" <kas@...nel.org>,
"seanjc@...gle.com" <seanjc@...gle.com>, "dwmw@...zon.co.uk"
<dwmw@...zon.co.uk>, "rdunlap@...radead.org" <rdunlap@...radead.org>,
"vegard.nossum@...cle.com" <vegard.nossum@...cle.com>, "xin@...or.com"
<xin@...or.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "linux-doc@...r.kernel.org"
<linux-doc@...r.kernel.org>, "kees@...nel.org" <kees@...nel.org>,
"hpa@...or.com" <hpa@...or.com>, "peterz@...radead.org"
<peterz@...radead.org>, "geert@...ux-m68k.org" <geert@...ux-m68k.org>
Subject: Re: [PATCH v10 08/15] x86/vsyscall: Reorganize the page fault
emulation code
On Tue, 2025-10-07 at 11:48 -0700, Dave Hansen wrote:
> On 10/7/25 11:37, Edgecombe, Rick P wrote:
> > > /*
> > > * No point in checking CS -- the only way to get here is a user mode
> > > * trap to a high address, which means that we're in 64-bit user code.
> > I don't know. Is this as true any more? We are now sometimes guessing based on
> > regs->ip of a #GP. What if the kernel accidentally tries to jump to the vsyscall
> > address? Then we are reading the kernel stack and strange things. Maybe it's
> > worth replacing the comment with a check? Feel free to call this paranoid.
>
> The first check in emulate_vsyscall() is:
>
> /* Write faults or kernel-privilege faults never get fixed up. */
> if ((error_code & (X86_PF_WRITE | X86_PF_USER)) != X86_PF_USER)
> return false;
>
> If the kernel jumped to the vsyscall page, it would end up there, return
> false, and never reach the code near the "No point in checking CS" comment.
>
> Right? Or am I misunderstanding the scenario you're calling out?
>
> If I'm understanding it right, I'd be a bit reluctant to add a CS check
> as well.
Sorry, I could have been clearer. Yes, I assumed that the comment was talking
about that check you quote.
But I'm looking at this applied. The following patches (which don't include that
hunk), add another call site:
bool emulate_vsyscall_gp(struct pt_regs *regs)
{
if (!cpu_feature_enabled(X86_FEATURE_LASS))
return false;
/* Emulate only if the RIP points to the vsyscall address */
if (!is_vsyscall_vaddr(regs->ip))
return false;
return __emulate_vsyscall(regs, regs->ip);
}
If indeed we should add a check, it should probably go in one of the later
patches and not this one.
Powered by blists - more mailing lists