Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Missing memory barriers when updating and reading `mshv_ready` allows 
concurrent userspace opens to access uninitialized driver state on 
weakly-ordered architectures.
--

--- Patch [5]: [PATCH v3 5/7] mshv: detect and report SEV-SNP support at init 
---
commit fb8f9421bc97a7ed49258a973cb3c9b05f5b3049
Author: Wei Liu <[email protected]>

mshv: detect and report SEV-SNP support at init

This commit queries MSHV dynamic processor features during parent
initialization to report SEV-SNP availability and the maximum number
of encrypted partitions. It also introduces a readiness flag to reject
userspace opens until initialization is complete.

> 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
[ ... ]
> @@ -2757,7 +2759,7 @@ static long mshv_dev_ioctl(struct file *filp, unsigned 
> int ioctl,
>  static int
>  mshv_dev_open(struct inode *inode, struct file *filp)
>  {
> -     return 0;
> +     return READ_ONCE(mshv_ready) ? 0 : -EAGAIN;

[Severity: High]
Since READ_ONCE() does not provide a load-acquire barrier, could subsequent
loads in the ioctl path be reordered on weakly-ordered architectures like
ARM64?

If a userspace process concurrently opens the device and calls an ioctl
while the module is initializing, it might observe mshv_ready as true but
still access uninitialized driver structures. Would using smp_load_acquire()
here prevent this reordering?

[ ... ]
> @@ -3022,6 +3124,7 @@ static int __init mshv_parent_partition_init(void)
>       hash_init(mshv_root.pt_htable);
>  
>       hv_setup_mshv_handler(mshv_isr);
> +     WRITE_ONCE(mshv_ready, true);

[Severity: High]
Because WRITE_ONCE() lacks a store-release barrier, is it possible for the
CPU to commit this store before the preceding stores that initialize the
driver state, such as the workqueue allocation or mshv_root.pt_htable?

Using smp_store_release() instead would ensure all preceding initialization
is globally visible before userspace can successfully open the device.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=5

Reply via email to