From: "Jan Beulich" Subject: Re: [PATCH] x86-64: don't allow non-canonical addresses to be set for any callback Date: Wed, 13 Jun 2012 12:20:50 +0100 Message-ID: <4FD893B20200007800089B82@nat28.tlf.novell.com> References: <4FD881530200007800089ACB@nat28.tlf.novell.com> <4FD870A8.6030606@cantab.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4FD870A8.6030606@cantab.net> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel Cc: xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 13.06.12 at 12:51, David Vrabel wrote: > On 13/06/12 11:02, Jan Beulich wrote: >> Rather than deferring the detection of these to the point where they >> get actually used (the fix for XSA-7, 25480:76eaf5966c05, causing a #GP >> to be raised by IRET, which invokes the guest's [fragile] fail-safe >> callback), don't even allow such to be set. >> >> Signed-off-by: Jan Beulich >> >> --- a/xen/arch/x86/domain.c >> +++ b/xen/arch/x86/domain.c >> @@ -736,6 +736,14 @@ int arch_set_info_guest( >> { >> if ( !compat ) >> { >> +#ifdef __x86_64__ >> + if ( !is_canonical_address(c.nat->user_regs.eip) || >> + !is_canonical_address(c.nat->event_callback_eip) || >> + !is_canonical_address(c.nat->syscall_callback_eip) || >> + !is_canonical_address(c.nat->failsafe_callback_eip) ) >> + return -EINVAL; >> +#endif >> + > > Would it be better to have > > #ifndef __x86_64__ > # define is_canonical_address(a) 1 > #endif > > somewhere? That one we have (otherwise other changes in this patch would cause build failures), the problem here is that ->syscall_callback doesn't exist for the 32-bit interface. And rater than just putting that on line into a conditional, I preferred to frame the whole addition. Jan