|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] memory: check incoming GFNs
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.
> > "...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.
> > "[I]n fact,
> > XENMEM_memory_exchange is known to be used in such ways" -- who's
> > using it in what ways? Are we talking about attacks in the wild, and
> > if so, why is this not an XSA?
>
> Does it really matter here who exactly is using the interfaces this
> way? Or whether all such uses are gone (of which I'm not sure)? Okay,
> I've added "(e.g. by Linux, at least up to a certain point)".
>
> > If not, who's using it how, and is that a good thing or not?
>
> Can doing things not the way they're specified by a good thing?
It's totally legit to say, "We originally envisioned it to be used in
manner X, with restriction Y. But it turns out, restriction Y was
superfluous, and people discovered that it can be used in manner Z
instead. And Z is cool! So, we've decided to bless Z as an approved
use, and officially remove restriction Y."
> And is "how" relevant here at all?
"Who and how" is part of whether it's something we should explicitly
bless, something we should remove immediately, or something we have to
accommodate for backwards compatibility reasons. It also sets
parameters for how best to bless it, or how best to accommodate it.
> 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.
Neither reviewers, nor maintainers, nor developers years hence, should
be expected to have those facts at the forefront of their mind; nor
should they be expected to spend hours digging around to discover
them. They should be in the commit message. You can have my R-b when
you have a commit message that includes them. Everything else I'm
easy about.
> >> @@ -903,6 +923,18 @@ static long memory_exchange(XEN_GUEST_HA
> >> continue;
> >> }
> >>
> >> + /*
> >> + * PV domains are known to pass arbitrary PFNs into this
> >> hypercall.
> >> + * Therefore we cannot apply the alignment check there.
> >> + */
> >
> > Worth being explicit here, so that in 20 years' time, someone can
> > consider whether we can drop the exception?
>
> Explicit about what? That some use in Linux has gone away at some point,
> but it's unclear where else uses may still exist? I'd rather not.
Yes, being explicit about what versions of Linux are known to need
this accommodation. Probably we'll keep the exception around forever.
But maybe there will come a time when keeping the exception is more
painful than dropping support for versions of Linux pre-5.15. We
shouldn't assume we know enough to tell those future developers they
must never get rid of this exception; we should give those future
developers the information they need to make the decision for
themselves.
-George
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |