On 12/8/25 14:51, Ariadne Conill wrote:
> We need to do this so that we can signal to the other end that the
> device is being removed, so that it will release its claim on the
> underlying memory allocation.  Otherwise releasing the grant-table
> entries is deferred resulting in a kernel oops since the pages have
> already been freed.

I don't think this is sufficient.  The backend can simply refuse
to release the grants.  The frontend needs to ensure that the pages
are not freed until the grant table entries are freed.  Right now,
the backend can cause a use-after-free in the frontend, and my
understanding of the Xen Project's security policy is that this is
a security vulnerability in the frontend code.

My instinct is that the core Xen code should take a reference on
each page before granting it to another domain, and not release that
reference until the pages are no longer granted.  This should prevent
any use-after-free problems if I understand Linux core MM correctly.

> Cc: Juergen Gross <[email protected]>
> Cc: Stefano Stabellini <[email protected]>
> Fixes: 71ebd71921e45 ("xen/9pfs: connect to the backend")
> Signed-off-by: Ariadne Conill <[email protected]>
> Signed-off-by: Alex Zenla <[email protected]>
> ---
>  net/9p/trans_xen.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
> index b9ff69c7522a..cde283c42dc6 100644
> --- a/net/9p/trans_xen.c
> +++ b/net/9p/trans_xen.c
> @@ -312,6 +312,7 @@ static void xen_9pfs_front_remove(struct xenbus_device 
> *dev)
>  {
>       struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev);
>  
> +     xenbus_switch_state(dev, XenbusStateClosing);
>       dev_set_drvdata(&dev->dev, NULL);
>       xen_9pfs_front_free(priv);
>  }


-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

Attachment: OpenPGP_0xB288B55FFF9C22C1.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to