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

Re: [PATCH v2] memory: check incoming GFNs


  • To: George Dunlap <gwd@xxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 18 Nov 2026 11:42:18 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • 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: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Community Manager <community.manager@xxxxxxxxxxxxxx>
  • Delivery-date: Wed, 18 Nov 2026 10:42:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17.11.2026 18:31, George Dunlap wrote:
> On Tue, Nov 17, 2026 at 2:06 PM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>> OK, so to begin with, this commit message hardly tells me anything I
>>> need to know.  "At best undefined", ok, but is that a problem?
>>
>> Maybe I've done / looked at too many UB patches over the last so many
>> years: To me it is out of question that UB is bad.
> 
> Our code isn't a hard-to-change standard.  If we want to define what
> something means, we can just do it.  It's only a problem if (as seems
> the case) code is written which assumes it's going to be aligned.
> 
>>>  "For
>>> non-translated domains the same isn't true" -- sorry, does that mean
>>> behavior is worse than "at best undefined", or better?
>>
>> It's different. I'm not sure I'd call it "better" or "worse". Hence the
>> mere fact being stated.
> 
> But you're saying what it isn't, not what it is.  "For non-translated
> domains, it isn't true that unaligned accesses are at best undefined."
>  What does that even mean?  I mean, now I know that you probably mean,
> "For translated domains, unaligned accesses are problematic due to the
> P2M's inherent tree structure.  On non-translated domains, gpfns are
> just a jumble of numbers, so unaligned accesses aren't as
> problematic."  That's not any longer than what you wrote, but it
> actually makes it clear which is a problem and points you in the
> direction of why.

But "aren't as problematic" isn't what I want to express. There really
should never have been a difference between translated and non-
translated. It's just that the bad behavior was leveraged (or, see
below, utilized) by carelessly written code which now we must not break.

And btw, for translated domains the P2M structure also doesn't impose
any constraints. Instead I view it as our desire that we want to
reflect requests optimally in the P2M. Extents could have been
expressed differently in the interface, in particular with size and
alignment not tied together at all. For input extents there could have
been merely a size, leaving it to the caller to specify suitably
aligned start frame numbers. Alignment requirements really are
necessary only for what is to be allocated.

Overall I think my way of putting it still better fits the overall
fuzzy situation.

>>> "...and domains
>>> may possibly be able to leverage present behavior" --   Is this
>>> attackers leveraging the present behavior to do evil, or clever OS
>>> writers leveraging the present behavior for good?
>>
>> Or careless OS writers adjusting their code only until it works, not
>> until it matches the (largely unwritten) spec.
> 
> "Leverage" implies gaining some advantage.  I wouldn't say that people
> who wrote non-spec-compliant code that accidentally works to be
> "leveraging" the behavior.

Is "utilize" any better then?

>> Claude's description, while - as you say - helpful for you, isn't how
>> I'd like to see patch descriptions written. Many of your recent
>> descriptions resemble that style, and I'm only not opposing to that
>> because it's not wrong to do it like this. Still I, as a maintainer,
>> am not happy with such overly verbose descriptions. They remove focus
>> from the actual change / problem.
> 
> Your description made clear neither the change nor the problem.
> 
> The following facts need to be known to evaluate the patch properly:
> 
> - The public headers of XENMEM_{populate,decrease,exchange} say that
> gpfns must be order-aligned, but the code has never enforced it.
> 
> - This is particularly problematic for translated domains [because of
> how the P2M works?].  There's already been an XSA relating to the
> above.
> 
> - Linux, up until 5.15, passed unaligned entries to XENMEM_exchange,
> so we have to accommodate this for backwards compatibility.

Well, okay, I've re-written (extended) those parts. As I'm uncertain
whether Linux'es use of the behavior is fully gone (and hence whether
5.15 is a valid boundary to draw), I'm going to continue to omit that
detail though.

Jan



 


Rackspace

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