[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 5/5] x86/vPIC: check values loaded from state save record
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Wed, 22 Nov 2023 11:22:58 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Dt+eH6WhvJViIB34I4PFCE4faK683QNMVq2grwObIPo=; b=kx+ZXSpFayPYfCr1l0RrZitmZJVVIeadOK8yezoAoqlTGy+ffxfjJqCkQpjKLz1U7XG5VlumN+c/IjIcuTz4Uxj5+9G4THuMQV+qp7DNvqLSiFcEI51f7FmnuoVjtBWU17f/n5Rtq6pP9sDvSPaNTIAd1Ya2q4l7y2QfhAnuu27O9qoXUj9n+7aol9ReSStFMCOPOEwTch2OHZEvMSd9DBEgx8UOjB5PFc2dSstVtWNPNSJanS3CASZnkwIgiqpxmamrFG0zEQmnepXgvlrWBjcOya3dbVcE5k63DLDHOoER7cVy3Pacze4KWAe/yEmA8GLC1PjycQZYOY+K3b9M3Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VCWfh/DFNxSQocyRbxstjejBCDV6TwYMKTHh+QO2YMbUAm8y3WuFqm8JUVPELrV5QttQnlFeZ0laQOmLd+vHK8dJybWZA9qom/JK+2p4PwlJ/00KGOoTRZeSu3280+Csp8jEhOHW9XvkrP8XV08K6XcEe7EKasBYC8z9ibH6NQxZuYDBR1a8SvTIsC7uAAoPUguYCNMsCpC7TsghKt50ncAIAQb0oNA4Bx6LweroVrO0QR7BmuIUnzeOkrfAYO9/1oOBp5+aNCnO0+Vqty7A6emoOkP0uTfInER290/RHhrHAEzIA9/UskkgY16kCWzddRjzsccbyDc92ZrzThezvA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
- Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Wed, 22 Nov 2023 10:23:13 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 22.11.2023 02:26, Andrew Cooper wrote:
> On 16/11/2023 1:48 pm, Jan Beulich wrote:
>> Loading is_master from the state save record can lead to out-of-bounds
>> accesses via at least the two container_of() uses by vpic_domain() and
>> __vpic_lock(). Make sure the value is consistent with the instance being
>> loaded.
>>
>> For ->int_output (which for whatever reason isn't a 1-bit bitfield),
>> besides bounds checking also take ->init_state into account.
>>
>> For ELCR follow what vpic_intercept_elcr_io()'s write path and
>> vpic_reset() do, i.e. don't insist on the internal view of the value to
>> be saved. Adjust vpic_elcr_mask() to allow using it easily for the new
>> case, but still also especially in the 2nd of the uses by
>> vpic_intercept_elcr_io()).
>
> I'm afraid I'm totally lost trying to follow this change.
>
> What is mb2 and why is it variable?
Master bit 2 (i.e. the value for bit 2 iff dealing with the master PIC).
I'm afraid I couldn't think of anything better that wouldn't be unduly
long.
> This does look like a logically unrelated change (the only overlap is
> using the new vpic_elcr_mask() form to audit the incoming data), so I
> think it needs breaking out simply for review-ability.
I can split it out, but I'm afraid it makes little sense when split. So
I'd first like to double check with you that with the naming choice
clarified, you still think you'd see this making sense as a change on
its own.
>> --- a/xen/arch/x86/hvm/vpic.c
>> +++ b/xen/arch/x86/hvm/vpic.c
>> @@ -35,13 +35,13 @@
>> #include <asm/hvm/save.h>
>>
>> #define vpic_domain(v) (container_of((v), struct domain, \
>> - arch.hvm.vpic[!vpic->is_master]))
>> + arch.hvm.vpic[!(v)->is_master]))
>
> This appears to have only compiled before because both callers have vpic
> as their parameter.
Indeed.
> I think this is worthy of breaking out into a separate change, because
> it wants backporting further than I expect you're likely to want to
> backport this patch in general.
Can do. Since there's no breakage from this, I wouldn't have thought of
backporting the change, though. Hence also why I folded it into here.
Jan
|