All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mukesh R" <mrathor@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v5 1/9] mshv: Provide a way to get partition ID if running in a VMM process
Date: Fri, 31 Jul 2026 22:47:39 +0000	[thread overview]
Message-ID: <20260731224740.5A5ED1F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260731223427.2554388-2-mrathor@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Using `current->tgid` for implicit VM partition binding restricts multi-process architectures, introduces PID reuse vulnerabilities (Privilege Escalation and DoS), and causes spurious creation failures.

Pre-existing issues:
- [Critical] Unchecked virtual processor (VP) access in `mshv_try_assert_irq_fast` can lead to a kernel panic.
--

--- Patch [1]: [PATCH v5 1/9] mshv: Provide a way to get partition ID if running in a VMM process ---
commit c09a2034eaac3e66996c48aebdd226e834f0611e
Author: Mukesh R <mrathor@linux.microsoft.com>

mshv: Provide a way to get partition ID if running in a VMM process

This commit adds a field to the MSHV partition structure to save the
tgid of the VMM process that created it. It also introduces a helper to
retrieve the partition ID by matching the current tgid and restricts
creation to one partition per VMM instance.

> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
[ ... ]
> +u64 mshv_current_partid(void)
> +{
> +	struct mshv_partition *pt;
> +	int i;
> +	u64 ret_ptid = HV_PARTITION_ID_INVALID;
> +
> +	rcu_read_lock();
> +
> +	hash_for_each_rcu(mshv_root.pt_htable, i, pt, pt_hnode) {
> +		if (pt->pt_vmm_tgid == current->tgid) {
> +			ret_ptid = pt->pt_id;
> +			break;
> +		}
> +	}
> +
> +	rcu_read_unlock();
> +	return ret_ptid;
> +}
> +EXPORT_SYMBOL_GPL(mshv_current_partid);
> +
> +/* At present, we only allow one partition per VMM instance */
>  static int
>  add_partition(struct mshv_partition *partition)
>  {
> +	int rc = 0;
> +
>  	spin_lock(&mshv_root.pt_ht_lock);
>  
> +	if (mshv_current_partid() != HV_PARTITION_ID_INVALID) {
> +		rc = -EEXIST;
> +		goto out;
> +	}
> +
> +	partition->pt_vmm_tgid = current->tgid;

[Severity: High]
Does using current->tgid for implicit VM partition binding introduce risks
with process lifecycle and PID reuse?

If a VMM process creates a partition, passes the file descriptor to another
process (e.g., via a UNIX socket) and exits, the original tgid could be
recycled for a new, unrelated process.

If that new process performs operations that invoke mshv_current_partid(),
could it incorrectly inherit the partition context of the previous process?

Alternatively, if the new process attempts to create its own partition in
add_partition(), would it incorrectly fail with -EEXIST?

[Severity: Critical]
This is a pre-existing issue, but I noticed a potential unchecked access
during the review of this subsystem.

In drivers/hv/mshv_eventfd.c:mshv_try_assert_irq_fast():

    vp = partition->pt_vp_array[irq->lapic_apic_id];

    if (!vp->vp_register_page) {
        ...

If userspace sets up an irqfd routing entry with an APIC ID that has no
corresponding virtual processor created yet, will vp be NULL when fetched
from pt_vp_array?

If so, would the immediate dereference of vp->vp_register_page result in a
host kernel panic when the eventfd is signaled?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731223427.2554388-1-mrathor@linux.microsoft.com?part=1

  reply	other threads:[~2026-07-31 22:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 22:34 [PATCH v5 0/9] PCI passthru on Hyper-V Mukesh R
2026-07-31 22:34 ` [PATCH v5 1/9] mshv: Provide a way to get partition ID if running in a VMM process Mukesh R
2026-07-31 22:47   ` sashiko-bot [this message]
2026-07-31 22:34 ` [PATCH v5 2/9] mshv: Add declarations and definitions for VFIO-MSHV bridge device Mukesh R
2026-07-31 22:42   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 3/9] mshv: Introduce basic mshv bridge device for VFIO to build upon Mukesh R
2026-07-31 22:49   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 4/9] mshv: Add ioctl support for MSHV-VFIO bridge device Mukesh R
2026-07-31 22:49   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 5/9] mshv: Import data structs around device passthru from hyperv headers Mukesh R
2026-07-31 22:45   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 6/9] PCI: hv: Export hv_build_devid_type_pci() and change return type Mukesh R
2026-07-31 22:47   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 7/9] x86/hyperv: Implement Hyper-V virtual IOMMU Mukesh R
2026-07-31 22:48   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 8/9] mshv: Populate mmio mappings for PCI passthru Mukesh R
2026-07-31 22:54   ` sashiko-bot
2026-07-31 22:34 ` [PATCH v5 9/9] mshv: Disable movable regions upfront if device passthru Mukesh R
2026-07-31 22:57   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260731224740.5A5ED1F00AC4@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mrathor@linux.microsoft.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.