From f06b657197fba4c94592419f5476b658b04b1e31 Mon Sep 17 00:00:00 2001 From: Jacob Wang Date: Sun, 1 Aug 2021 13:37:55 +0800 Subject: [PATCH 1/2] Adjust to support virtiofsd minor > 27 Signed-off-by: Jacob Wang --- ...iofsd-Adjust-limit-for-minor-version.patch | 41 +++++++++++++++++++ qemu-kvm.spec | 8 +++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 kvm-virtiofsd-Adjust-limit-for-minor-version.patch diff --git a/kvm-virtiofsd-Adjust-limit-for-minor-version.patch b/kvm-virtiofsd-Adjust-limit-for-minor-version.patch new file mode 100644 index 0000000..30ec553 --- /dev/null +++ b/kvm-virtiofsd-Adjust-limit-for-minor-version.patch @@ -0,0 +1,41 @@ +From 3b7200134925fcf5ae99b5c3b34465456d3bc002 Mon Sep 17 00:00:00 2001 +From: Jacob Wang +Date: Mon, 2 Aug 2021 01:16:05 +0800 +Subject: [PATCH 1/1] virtiofsd: Adjust limit for minor version + +Upstream virtiofsd only supports fuse >= 7.31 +(https://github.com/qemu/qemu/commit/72c42e2d65510e073cf78fdc924d121c77fa0080), +while Cloud Kernel has fuse version 7.27, which causes virtiofs fails to run +due to version mismatch. This limitation is unnecessary in Cloud Kernel because +we have already backported mandatory fuse patches to support virtofs +frontend in Kernel. Hence, adjust the minor version limit to 7.27 to +suppress the limitation. + +Note that current fuse implementation in Cloud Kernel might lack of some +certain capabilities in fuse 7.28 ~ 7.31, which may cause unexpected results, +this patch is merely a workaround to enable virtiofs in guest kernel side and +further action is ongoing to make sure fuse APIs in both sides are 100% +compatible. + +Signed-off-by: Jacob Wang +Acked-by: Caspar Zhang +--- + tools/virtiofsd/fuse_lowlevel.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c +index 2dd36ec..2bb4318 100644 +--- a/tools/virtiofsd/fuse_lowlevel.c ++++ b/tools/virtiofsd/fuse_lowlevel.c +@@ -1917,7 +1917,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, + outarg.major = FUSE_KERNEL_VERSION; + outarg.minor = FUSE_KERNEL_MINOR_VERSION; + +- if (arg->major < 7 || (arg->major == 7 && arg->minor < 31)) { ++ if (arg->major < 7 || (arg->major == 7 && arg->minor < 27)) { + fuse_log(FUSE_LOG_ERR, "fuse: unsupported protocol version: %u.%u\n", + arg->major, arg->minor); + fuse_reply_err(req, EPROTO); +-- +1.8.3.1 + diff --git a/qemu-kvm.spec b/qemu-kvm.spec index 15c6a15..80e63fa 100644 --- a/qemu-kvm.spec +++ b/qemu-kvm.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %global SLOF_gittagdate 20191022 %global SLOF_gittagcommit 899d9883 @@ -67,7 +68,7 @@ Obsoletes: %1-rhev <= %{epoch}:%{version}-%{release} Summary: QEMU is a machine emulator and virtualizer Name: qemu-kvm Version: 4.2.0 -Release: 60%{?dist}.2 +Release: 60%{anolis_release}%{?dist}.2 # Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped Epoch: 15 License: GPLv2 and GPLv2+ and CC-BY @@ -1269,6 +1270,8 @@ Patch553: kvm-target-i386-Observe-XSAVE-state-area-offsets.patch # For bz#2065239 - KVM Fedora 35 guest x86 programs randomly crash in signal handler [rhel-8.5.0.z] Patch554: kvm-target-i386-Populate-x86_ext_save_areas-offsets-usin.patch +Patch1000: kvm-virtiofsd-Adjust-limit-for-minor-version.patch + BuildRequires: wget BuildRequires: rpm-build BuildRequires: zlib-devel @@ -2216,6 +2219,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %changelog +* Thu May 05 2022 Jacob Wang - 4.2.0-60.0.1.2 +- Adjust limit for virtiofsd minor version + * Tue Mar 22 2022 Jon Maloy - 4.2.0-60.el8_5.2 - kvm-target-i386-Declare-constants-for-XSAVE-offsets.patch [bz#2065239] - kvm-target-i386-Consolidate-the-X86XSaveArea-offset-chec.patch [bz#2065239] -- Gitee From 825f6045a744ccca843325fd7e17bcd350ce06d4 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Sat, 10 Oct 2020 23:49:32 +0800 Subject: [PATCH 2/2] Fix gcc10 build issue this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util upstream fixes build hit error with gcc10: scsi/qemu-pr-helper.c:523:32: error: array subscript is outside array bounds of 'struct transportid *[]' [-Werror=array-bounds] 523 | paramp.trnptid_list[paramp.num_transportid++] = id; backport upstream patch to fix this build issue Reviewed-by: Jacob Wang Signed-off-by: Liwei Ge (cherry picked from commit 3310dfd2b0ede197f2cb924388b069ee30162dd3) Signed-off-by: Caspar Zhang Signed-off-by: weitao zhou --- 1001-qemu-kvm-gcc10.patch | 92 +++++++++++++++++++++++++++++++++++++++ qemu-kvm.spec | 10 ++++- 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 1001-qemu-kvm-gcc10.patch diff --git a/1001-qemu-kvm-gcc10.patch b/1001-qemu-kvm-gcc10.patch new file mode 100644 index 0000000..af2545b --- /dev/null +++ b/1001-qemu-kvm-gcc10.patch @@ -0,0 +1,92 @@ +From 4ce1e15fbc7266a108a7c77a3962644b3935346e Mon Sep 17 00:00:00 2001 +From: Christophe de Dinechin +Date: Fri, 28 Feb 2020 16:00:59 +0100 +Subject: [PATCH] scsi/qemu-pr-helper: Fix out-of-bounds access to + trnptid_list[] +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Compile error reported by gcc 10.0.1: + +scsi/qemu-pr-helper.c: In function ‘multipath_pr_out’: +scsi/qemu-pr-helper.c:523:32: error: array subscript is outside array bounds of ‘struct transportid *[0]’ [-Werror=array-bounds] + 523 | paramp.trnptid_list[paramp.num_transportid++] = id; + | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ +In file included from scsi/qemu-pr-helper.c:36: +/usr/include/mpath_persist.h:168:22: note: while referencing ‘trnptid_list’ + 168 | struct transportid *trnptid_list[]; + | ^~~~~~~~~~~~ +scsi/qemu-pr-helper.c:424:35: note: defined here ‘paramp’ + 424 | struct prout_param_descriptor paramp; + | ^~~~~~ + +This highlights an actual implementation issue in function multipath_pr_out. +The variable paramp is declared with type `struct prout_param_descriptor`, +which is a struct terminated by an empty array in mpath_persist.h: + + struct transportid *trnptid_list[]; + +That empty array was filled with code that looked like that: + + trnptid_list[paramp.descr.num_transportid++] = id; + +This is an actual out-of-bounds access. + +The fix is to malloc `paramp`. + +Signed-off-by: Christophe de Dinechin +Signed-off-by: Paolo Bonzini +--- + scsi/qemu-pr-helper.c | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c +index 0659ceef098..181ed4a1861 100644 +--- a/scsi/qemu-pr-helper.c ++++ b/scsi/qemu-pr-helper.c +@@ -421,10 +421,13 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, + int rq_servact = cdb[1]; + int rq_scope = cdb[2] >> 4; + int rq_type = cdb[2] & 0xf; +- struct prout_param_descriptor paramp; ++ g_autofree struct prout_param_descriptor *paramp = NULL; + char transportids[PR_HELPER_DATA_SIZE]; + int r; + ++ paramp = g_malloc0(sizeof(struct prout_param_descriptor) ++ + sizeof(struct transportid *) * MPATH_MX_TIDS); ++ + if (sz < PR_OUT_FIXED_PARAM_SIZE) { + /* Illegal request, Parameter list length error. This isn't fatal; + * we have read the data, send an error without closing the socket. +@@ -454,10 +457,9 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, + * used by libmpathpersist (which, of course, will immediately + * do the opposite). + */ +- memset(¶mp, 0, sizeof(paramp)); +- memcpy(¶mp.key, ¶m[0], 8); +- memcpy(¶mp.sa_key, ¶m[8], 8); +- paramp.sa_flags = param[20]; ++ memcpy(¶mp->key, ¶m[0], 8); ++ memcpy(¶mp->sa_key, ¶m[8], 8); ++ paramp->sa_flags = param[20]; + if (sz > PR_OUT_FIXED_PARAM_SIZE) { + size_t transportid_len; + int i, j; +@@ -520,12 +522,13 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, + return CHECK_CONDITION; + } + +- paramp.trnptid_list[paramp.num_transportid++] = id; ++ assert(paramp->num_transportid < MPATH_MX_TIDS); ++ paramp->trnptid_list[paramp->num_transportid++] = id; + } + } + + r = mpath_persistent_reserve_out(fd, rq_servact, rq_scope, rq_type, +- ¶mp, noisy, verbose); ++ paramp, noisy, verbose); + return mpath_reconstruct_sense(fd, r, sense); + } + #endif diff --git a/qemu-kvm.spec b/qemu-kvm.spec index 80e63fa..16a2340 100644 --- a/qemu-kvm.spec +++ b/qemu-kvm.spec @@ -1270,7 +1270,12 @@ Patch553: kvm-target-i386-Observe-XSAVE-state-area-offsets.patch # For bz#2065239 - KVM Fedora 35 guest x86 programs randomly crash in signal handler [rhel-8.5.0.z] Patch554: kvm-target-i386-Populate-x86_ext_save_areas-offsets-usin.patch +# Begin: Anolis customized patches +# backport patch from upstream Patch1000: kvm-virtiofsd-Adjust-limit-for-minor-version.patch +Patch1001: 1001-qemu-kvm-gcc10.patch +# End: Anolis customized patches + BuildRequires: wget BuildRequires: rpm-build @@ -2219,8 +2224,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %changelog -* Thu May 05 2022 Jacob Wang - 4.2.0-60.0.1.2 -- Adjust limit for virtiofsd minor version +* Thu May 05 2022 Zhao Hang - 4.2.0-60.0.1.2 +- Adjust limit for virtiofsd minor version(Jacob Wang) +- Fix gcc10 build issue(Weitao Zhou) * Tue Mar 22 2022 Jon Maloy - 4.2.0-60.el8_5.2 - kvm-target-i386-Declare-constants-for-XSAVE-offsets.patch [bz#2065239] -- Gitee