From patchwork Tue Nov 9 12:47:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Heimes X-Patchwork-Id: 1552971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=bM9FyB+f; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HpSRs09rrz9sCD for ; Tue, 9 Nov 2021 23:47:20 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mkQWr-0003OR-0z; Tue, 09 Nov 2021 12:47:09 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mkQWo-0003Nn-TD for kernel-team@lists.ubuntu.com; Tue, 09 Nov 2021 12:47:06 +0000 Received: from T570.fritz.box (p5b1759c5.dip0.t-ipconnect.de [91.23.89.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id A47F53F17A for ; Tue, 9 Nov 2021 12:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1636462026; bh=TGL/ZV1yyoORmXtAvzvQDiuLUJ4fFVicShe/gQJouO0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=bM9FyB+fQ+ljiSqFJxS9i0mH7nJlcWy7ZC4NPiQpXs+RKBkyAUEeXKRIaNa80CcTI Pyyd9DNFgbHRiU8n40qpZGDKUQWd202ZkxsnBcu3SWthYjhUiYrRD2mVR2zyiR4wls izv/TyGa+nBcGdRNDTUH1v/BN6Te0Sn4xod5Ws6Bx7KXQGoaTkPRF8NAQmqDuGXplX 60JZSKVViNRnJ2zp7iMNe4FSOnykdCpO/kgKkLHKgqyLvh1f01QdweaeWQhXRKZTAV dA4nQKhf1RYCw0TCErsYOJYcQPIysywCTvkiRbOqHB8U9PpVdcJ5Df+ptS6k9iXllo TrM8eO0Xy4ZQw== From: frank.heimes@canonical.com To: kernel-team@lists.ubuntu.com Subject: [SRU][I][H][F][PATCH 0/1] kernel: unable to read partitions on virtio-block dasd (kvm) (LP: 1950144) Date: Tue, 9 Nov 2021 13:47:01 +0100 Message-Id: <20211109124702.2369200-1-frank.heimes@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1950144 SRU Justification: [Impact] * The kernel is unable to read partitions on virtio-block DASD (on KVM). That's a severe situation, since it prevents Ubuntu from starting, if installed on a DASD. This issue can either occur after a fresh installation or after an upgrade. * The virtio specification virtio-v1.1-cs01 states: "Transitional devices MUST detect Legacy drivers by detecting that VIRTIO_F_VERSION_1 has not been acknowledged by the driver." And this is what QEMU as of 6.1 has done relying solely on VIRTIO_F_VERSION_1 for detecting that. * But the specification also says: "... the driver MAY read (but MUST NOT write) the device-specific configuration fields to check that it can support the device ..." before setting FEATURES_OK. * In this case, any transitional device relying solely on VIRTIO_F_VERSION_1 for detecting legacy drivers will return data in legacy format. In particular, this implies that it's in big endian format for big endian guests. This naturally confuses the driver that expects little endian in the modern mode. * VIRTIO_F_VERSION_1 can only be relied on after the feature negotiation is done. * 'verify' is called before virtio_finalize_features(), so a transitional s390 virtio device still serves native endian (i.e. big endian) config space, while the driver knows that it is going to accept VERSION_1, so when reading the config space, it assumes it got little endian, and byteswaps. * For QEMU, we can work around the issue by writing out the feature bits with VIRTIO_F_VERSION_1 bit set. We (ab)use the finalize_features config op for this. This isn't enough to address all vhost devices since these do not get the features until FEATURES_OK, however it looks like the affected devices actually never handled the endianness for legacy mode correctly, so at least that's not a regression. [Fix] * 2f9a174f918e29608564c7a4e8329893ab604fb4 2f9a174f918e "virtio: write back F_VERSION_1 before validate" [Test Case] * Setup an IBM Z or LinuxONE LPAR with Ubuntu Server 20.04 as KVM host. * This Ubuntu KVM host can either be installed on FCP or DASD storage, but at least one DASD disk need to be reserved for a KVM guest. * Now hand over the reserved DASD disk (low-level formatted using dasdfmt and partitioned using fdasd) using 'virtio-block' to a KVM virtual machine (e.g. using a virsh VM config). * Try to install an Ubuntu KVM virtual machine using this DASD disk, that includes the check and read of the partition table. [Where problems could occur] * First of all requested commit contains one additional if statement; and is due tothat relatively traceable. * But the change is in /drivers/virtio/virtio.c, means in common code! * This issue obviously affects big endian systems only. * But if done wrong, it may effect in worst-case little endian systems, too! * But the if statement explicitly checks for '!virtio_legacy_is_little_endian()'. * Only virtio net and virtio blk devices seem to be affected. * And the commit/solutions was in-depth discussed upstream here: https://lore.kernel.org/all/20211011053921.1198936-1-pasic@linux.ibm.com/t/#u [Other] * Patches are upstream accepted with since 5.15-rc6 and tagged for upstream stable #v4.11. Hence jammy is not affected. * Request was to add the patches to focal / 20.04, but to avoid potential regressions on upgrades, the patches need to be added to impish and hirsute, too. * Fortunately cherry-picking the commit works cleanly from all the affected Ubuntu releases. Halil Pasic (1): virtio: write back F_VERSION_1 before validate drivers/virtio/virtio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Acked-by: Thadeu Lima de Souza Cascardo