[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] domain: Validate __copy_to_guest in VCPUOP_register_runstate_memory_area


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 26 Nov 2024 12:24:46 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l5lqJSGgo5KI//ZxXAOKdOP/SSGW4aoYTyRpz20sD+0=; b=vuxMeUFNr0tnESPT0evBFQy709zLHmv3mfenAUHJCZemF9JsCKK+DYQYdCKC3/BOuTZKANrOkltcMQtVvJty6yvoVPiCc5xb/RO5imsaD1EI1V6Fsm2lmOm4+G8Uy+sLwY01QP1bNt5drdXLooboUysTqyyc35TSLugK1hLJgCxsMOcCkK6AFWom4ePnyqy5X6mOXSgUsUHXcz3yWao1wz+WDze86XkhsGWlO8k+4BYRvjJg4q6uh253mvkpikqlFlFyys6JBuVM7fCQnPQAJI1HzTF15OW3AvDQqAkcUW2Mu1wl8d4RX2QtvcYqyjqKoOMo448KNs9HNmXN00ZGpA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IMkXctdOHi/803iF3qSNRiMqyC/2DJUuxsLHEsswm9bzghiJNa0d3EKXrP4yEGIxQ+GRpMTmBS8jJ7ottbBb0hS37VCvRMoqN/hsD7zeVhtd8GhOFaN1+u7QvgbgUY6ByCtjPnJbGHVUtBr2bqCUYkkyJA60sj7YlWYzkP5G59D4KFop2BvHS2qOcoUmh2csjBs/2tXEI21BWec4XnJ5bT0BVpRPTwfRYzMTVF0GmRDLRm1/Qlrwu4QDKh0OSSvTpQTiBcy7wtDMcXa9ey+JHuIVaeZNEXtP2YxaMQ5Sv+4SW99H6qyDfoP2pgu5o5ndexbHvtafNp+QjZqpLSVz8A==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 26 Nov 2024 11:25:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 26/11/2024 11:40, Jan Beulich wrote:
> 
> 
> On 26.11.2024 11:26, Michal Orzel wrote:
>> For guests with paging mode external, guest_handle_okay() always returns
>> success, even if the guest handle is invalid (e.g. address not in P2M).
>> In VCPUOP_register_runstate_memory_area, we would then blindly set
>> runstate_guest() for a given vCPU to invalid handle. Moreover, we don't
>> check the return value from __copy_to_guest() and return success to the
>> guest, even in case of a failure during copy.
> 
> I'm afraid this is all deliberate, providing best effort behavior. For a
> paging mode external guest, the handle may become valid subsequently. If
> any __copy_to_guest() fail here, subsequent update_runstate_area() may
> succeed (and success of the actual copying isn't checked there either).
Hmm, I've never looked at that this way. I always thought that mapping must be 
in place
before setting up handle. Is this concept really something used (e.g. in Linux) 
or just a
way for us to provide excuse for not hardening the code because of a fear of 
regressions, etc.?

> 
>> Fix it, by checking the
>> return value from __copy_to_guest() and set runstate_guest() only on
>> success.
> 
> _If_ such a change was wanted (despite its potential for regressions,
> as guests may leverage present behavior to establish handles before
> putting in place mappings), x86'es compat_vcpu_op() would need updating,
> too. Plus what about VCPUOP_register_vcpu_time_memory_area, behaving
> similarly?
It's up to us. If the concept you mentioned is valid and people are aware of 
it, then
let's keep as is. I for one was amazed that Xen returned success but structure 
was not
copied.

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.