Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anthony Krowiak" <akrowiak@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.vom>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v4 4/9] s390/vfio-ap: Fix required lock not held during update of ap_matrix_mdev object
Date: Wed, 12 Aug 2026 17:24:42 +0000	[thread overview]
Message-ID: <20260812172443.5BF551F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260812170945.738351-5-akrowiak@linux.ibm.com>

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

Pre-existing issues:
- [High] Hardware validation is skipped when an adapter is hotplugged without new domains, allowing unsupported hardware to be assigned.
--

--- Patch [4]: [PATCH v4 4/9] s390/vfio-ap: Fix required lock not held during update of ap_matrix_mdev object ---
commit 6a90ea8f2f04defd282ac1432c8f5ff791b149f2
Author: Anthony Krowiak <akrowiak@linux.ibm.com>

s390/vfio-ap: Fix required lock not held during update of ap_matrix_mdev object

This patch resolves a missing lock issue in vfio_ap_mdev_cfg_add(). It ensures
that the mdevs_lock is held while modifying the apm_add, aqm_add, and adm_add
bitmap fields. This prevents race conditions with concurrent modifications to
the matrix device.

> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index f2d662e388bdc..21c502598f8ca 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -2777,12 +2777,20 @@ static void vfio_ap_mdev_cfg_add(unsigned long *apm_add, unsigned long *aqm_add,

[Severity: High]
This isn't a bug introduced by this patch, but does 
vfio_ap_filter_apid_by_qtype() skip hardware validation if an adapter is 
hotplugged without new domains?

In vfio_ap_filter_apid_by_qtype(), if aqm is empty:

drivers/s390/crypto/vfio_ap_ops.c:vfio_ap_filter_apid_by_qtype() {
...
    for_each_set_bit_inv(apid, apm, AP_DEVICES) {
        apid_cleared = false;

        for_each_set_bit_inv(apqi, aqm, AP_DOMAINS) {
            status = ap_test_queue(AP_MKQID(apid, apqi), 1, &info);
...
}

The inner loop iterating over aqm (which maps to aqm_add) will not execute
if no domains were added during the config change. As a result, the hardware
is never queried with ap_test_queue(), and unsupported older adapters (older
than CEX4) are not filtered out from apm_add.

Can this allow unsupported hardware to be assigned to a KVM guest if a host
administrator hotplugs an older AP adapter without simultaneously hotplugging
new domains?

>  	 * called.
>  	 */
>  	list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) {
> +		/*
> +		 * The mdevs_lock must be held in order to access fields
> +		 * within matrix_mdev
> +		 */
> +		mutex_lock(&matrix_dev->mdevs_lock);
> +
>  		bitmap_and(matrix_mdev->apm_add,
>  			   matrix_mdev->matrix.apm, apm_add, AP_DEVICES);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812170945.738351-1-akrowiak@linux.ibm.com?part=4

  reply	other threads:[~2026-08-12 17:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 17:09 [PATCH v4 0/9] s390/vfio-ap: Fix bugs in vfio_ap device driver callback functions Anthony Krowiak
2026-08-12 17:09 ` [PATCH v4 1/9] s390/vfio-ap: Fix stale do_remove flag across iterations in vfio_ap_mdev_cfg_remove Anthony Krowiak
2026-08-12 17:22   ` sashiko-bot
2026-08-12 17:09 ` [PATCH v4 2/9] s390/vfio-ap: Fix dereference matrix_mdev->kvm without checking for NULL Anthony Krowiak
2026-08-12 17:28   ` sashiko-bot
2026-08-12 17:09 ` [PATCH v4 3/9] s390/vfio-ap: Fix missing lock required to access list of ap_matrix_mdev objects Anthony Krowiak
2026-08-12 17:28   ` sashiko-bot
2026-08-12 18:25     ` Anthony Krowiak
2026-08-12 17:09 ` [PATCH v4 4/9] s390/vfio-ap: Fix required lock not held during update of ap_matrix_mdev object Anthony Krowiak
2026-08-12 17:24   ` sashiko-bot [this message]
2026-08-12 17:09 ` [PATCH v4 5/9] s390/vfio-ap: Fix control domain removal in vfio_ap_mdev_cfg_remove Anthony Krowiak
2026-08-12 17:19   ` sashiko-bot
2026-08-12 17:09 ` [PATCH v4 6/9] s390/vfio-ap: fix potential use of uninitialized apm_filtered bitmap Anthony Krowiak
2026-08-12 17:17   ` sashiko-bot
2026-08-12 17:09 ` [PATCH v4 7/9] s390/vfio-ap: Fix hot-unplug skipped when last AP adapter or domain removed Anthony Krowiak
2026-08-12 17:24   ` sashiko-bot
2026-08-12 17:09 ` [PATCH v4 8/9] s390/vfio-ap: Fix NULL deref in status_show() during queue probe Anthony Krowiak
2026-08-12 17:27   ` sashiko-bot
2026-08-12 17:58   ` Matthew Rosato
2026-08-12 18:16     ` Anthony Krowiak
2026-08-12 17:09 ` [PATCH v4 9/9] s390/vfio-ap: Fix memory leak when queue removed from host AP config Anthony Krowiak
2026-08-12 17:38   ` 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=20260812172443.5BF551F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=borntraeger@linux.ibm.vom \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox