stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Alexander Graf <graf@amazon.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 6.0 18/94] KVM: x86: Copy filter arg outside kvm_vm_ioctl_set_msr_filter()
Date: Thu, 27 Oct 2022 18:54:20 +0200	[thread overview]
Message-ID: <20221027165057.802876819@linuxfoundation.org> (raw)
In-Reply-To: <20221027165057.208202132@linuxfoundation.org>

From: Alexander Graf <graf@amazon.com>

commit 2e3272bc1790825c43d2c39690bf2836b81c6d36 upstream.

In the next patch we want to introduce a second caller to
set_msr_filter() which constructs its own filter list on the stack.
Refactor the original function so it takes it as argument instead of
reading it through copy_from_user().

Signed-off-by: Alexander Graf <graf@amazon.com>
Message-Id: <20221017184541.2658-3-graf@amazon.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/kvm/x86.c |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6406,26 +6406,22 @@ static int kvm_add_msr_filter(struct kvm
 	return 0;
 }
 
-static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm, void __user *argp)
+static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm,
+				       struct kvm_msr_filter *filter)
 {
-	struct kvm_msr_filter __user *user_msr_filter = argp;
 	struct kvm_x86_msr_filter *new_filter, *old_filter;
-	struct kvm_msr_filter filter;
 	bool default_allow;
 	bool empty = true;
 	int r = 0;
 	u32 i;
 
-	if (copy_from_user(&filter, user_msr_filter, sizeof(filter)))
-		return -EFAULT;
-
-	if (filter.flags & ~KVM_MSR_FILTER_DEFAULT_DENY)
+	if (filter->flags & ~KVM_MSR_FILTER_DEFAULT_DENY)
 		return -EINVAL;
 
-	for (i = 0; i < ARRAY_SIZE(filter.ranges); i++)
-		empty &= !filter.ranges[i].nmsrs;
+	for (i = 0; i < ARRAY_SIZE(filter->ranges); i++)
+		empty &= !filter->ranges[i].nmsrs;
 
-	default_allow = !(filter.flags & KVM_MSR_FILTER_DEFAULT_DENY);
+	default_allow = !(filter->flags & KVM_MSR_FILTER_DEFAULT_DENY);
 	if (empty && !default_allow)
 		return -EINVAL;
 
@@ -6433,8 +6429,8 @@ static int kvm_vm_ioctl_set_msr_filter(s
 	if (!new_filter)
 		return -ENOMEM;
 
-	for (i = 0; i < ARRAY_SIZE(filter.ranges); i++) {
-		r = kvm_add_msr_filter(new_filter, &filter.ranges[i]);
+	for (i = 0; i < ARRAY_SIZE(filter->ranges); i++) {
+		r = kvm_add_msr_filter(new_filter, &filter->ranges[i]);
 		if (r) {
 			kvm_free_msr_filter(new_filter);
 			return r;
@@ -6879,9 +6875,16 @@ set_pit2_out:
 	case KVM_SET_PMU_EVENT_FILTER:
 		r = kvm_vm_ioctl_set_pmu_event_filter(kvm, argp);
 		break;
-	case KVM_X86_SET_MSR_FILTER:
-		r = kvm_vm_ioctl_set_msr_filter(kvm, argp);
+	case KVM_X86_SET_MSR_FILTER: {
+		struct kvm_msr_filter __user *user_msr_filter = argp;
+		struct kvm_msr_filter filter;
+
+		if (copy_from_user(&filter, user_msr_filter, sizeof(filter)))
+			return -EFAULT;
+
+		r = kvm_vm_ioctl_set_msr_filter(kvm, &filter);
 		break;
+	}
 	default:
 		r = -ENOTTY;
 	}



  parent reply	other threads:[~2022-10-27 16:57 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 16:54 [PATCH 6.0 00/94] 6.0.6-rc1 review Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 01/94] [PATCH v2] video/aperture: Call sysfb_disable() before removing PCI devices Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 02/94] ocfs2: clear dinode links count in case of error Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 03/94] ocfs2: fix BUG when iput after ocfs2_mknod fails Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 04/94] smb3: interface count displayed incorrectly Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 05/94] selinux: enable use of both GFP_KERNEL and GFP_ATOMIC in convert_context() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 06/94] cpufreq: qcom: fix writes in read-only memory region Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 07/94] i2c: qcom-cci: Fix ordering of pm_runtime_xx and i2c_add_adapter Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 08/94] cpufreq: tegra194: Fix module loading Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 09/94] x86/microcode/AMD: Apply the patch early on every logical thread Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 10/94] hwmon/coretemp: Handle large core ID value Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 11/94] ata: ahci-imx: Fix MODULE_ALIAS Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 12/94] ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 13/94] x86/resctrl: Fix min_cbm_bits for AMD Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 14/94] cpufreq: qcom: fix memory leak in error path Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 15/94] drm/amdgpu: fix sdma doorbell init ordering on APUs Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 16/94] mm,hugetlb: take hugetlb_lock before decrementing h->resv_huge_pages Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 17/94] kvm: Add support for arch compat vm ioctls Greg Kroah-Hartman
2022-10-27 16:54 ` Greg Kroah-Hartman [this message]
2022-10-27 16:54 ` [PATCH 6.0 19/94] KVM: x86: Add compat handler for KVM_X86_SET_MSR_FILTER Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 20/94] KVM: arm64: vgic: Fix exit condition in scan_its_table() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 21/94] media: ipu3-imgu: Fix NULL pointer dereference in active selection access Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 22/94] media: mceusb: set timeout to at least timeout provided Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 23/94] media: venus: dec: Handle the case where find_format fails Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 24/94] media: venus: Fix NV12 decoder buffer discovery on HFI_VERSION_1XX Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 25/94] x86/Kconfig: Drop check for -mabi=ms for CONFIG_EFI_STUB Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 26/94] x86/topology: Fix multiple packages shown on a single-package system Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 27/94] x86/topology: Fix duplicated core ID within a package Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 28/94] platform/x86/amd: pmc: Read SMU version during suspend on Cezanne systems Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 29/94] dm bufio: use the acquire memory barrier when testing for B_READING Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 30/94] btrfs: fix processing of delayed data refs during backref walking Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 31/94] btrfs: fix processing of delayed tree block " Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 32/94] drm/vc4: Add module dependency on hdmi-codec Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 33/94] drm/vc4: hdmi: Enforce the minimum rate at runtime_resume Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 34/94] ACPI: extlog: Handle multiple records Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 35/94] tipc: Fix recognition of trial period Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 36/94] tipc: fix an information leak in tipc_topsrv_kern_subscr Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 37/94] net: dsa: qca8k: fix inband mgmt for big-endian systems Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 38/94] net: dsa: qca8k: fix ethtool autocast mib " Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 39/94] i40e: Fix DMA mappings leak Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 40/94] tls: strp: make sure the TCP skbs do not have overlapping data Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 41/94] HID: magicmouse: Do not set BTN_MOUSE on double report Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 42/94] sfc: Change VF mac via PF as first preference if available Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 43/94] net/atm: fix proc_mpc_write incorrect return value Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 44/94] net: phy: dp83867: Extend RX strap quirk for SGMII mode Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 45/94] net/smc: Fix an error code in smc_lgr_create() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 46/94] net: phylink: add mac_managed_pm in phylink_config structure Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 47/94] net: stmmac: Enable mac_managed_pm phylink config Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 48/94] skmsg: pass gfp argument to alloc_sk_msg() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 49/94] erofs: shouldnt churn the mapping page for duplicated copies Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 50/94] blk-mq: fix null pointer dereference in blk_mq_clear_rq_mapping() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 51/94] io_uring/rw: remove leftover debug statement Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 52/94] net: ethernet: mtk_eth_soc: fix possible memory leak in mtk_probe() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 53/94] net: ethernet: mtk_eth_wed: add missing put_device() in mtk_wed_add_hw() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 54/94] net: ethernet: mtk_eth_wed: add missing of_node_put() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 55/94] scsi: lpfc: Fix memory leak in lpfc_create_port() Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 56/94] udp: Update reuse->has_conns under reuseport_lock Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 6.0 57/94] ip6mr: fix UAF issue in ip6mr_sk_done() when addrconf_init_net() failed Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 58/94] cifs: Fix xid leak in cifs_create() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 59/94] cifs: Fix xid leak in cifs_copy_file_range() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 60/94] cifs: Fix xid leak in cifs_flock() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 61/94] cifs: Fix xid leak in cifs_ses_add_channel() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 62/94] cifs: Fix memory leak when build ntlmssp negotiate blob failed Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 63/94] dm: remove unnecessary assignment statement in alloc_dev() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 64/94] drm/amd/display: Increase frame size limit for display_mode_vba_util_32.o Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 65/94] bnxt_en: fix memory leak in bnxt_nvm_test() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 66/94] net: hsr: avoid possible NULL deref in skb_clone() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 67/94] ionic: catch NULL pointer issue on reconfig Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 68/94] netfilter: rpfilter/fib: Populate flowic_l3mdev field Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 69/94] netfilter: rpfilter/fib: Set ->flowic_uid correctly for user namespaces Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 70/94] netfilter: nf_tables: relax NFTA_SET_ELEM_KEY_END set flags requirements Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 71/94] nvme-hwmon: consistently ignore errors from nvme_hwmon_init Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 72/94] nvme-hwmon: kmalloc the NVME SMART log buffer Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 73/94] nvmet: fix workqueue MEM_RECLAIM flushing dependency Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 74/94] net: sched: cake: fix null pointer access issue when cake_init() fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 75/94] net: sched: delete duplicate cleanup of backlog and qlen Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 76/94] net: sched: sfb: fix null pointer access issue when sfb_init() fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 77/94] net: Fix return value of qdisc ingress handling on success Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 78/94] io_uring/msg_ring: Fix NULL pointer dereference in io_msg_send_fd() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 79/94] sfc: include vport_id in filter spec hash and equal() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 80/94] wwan_hwsim: fix possible memory leak in wwan_hwsim_dev_new() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 81/94] net: hns: fix possible memory leak in hnae_ae_register() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 82/94] net: sched: fix race condition in qdisc_graft() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 83/94] net: phy: dp83822: disable MDI crossover status change interrupt Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 84/94] drbd: only clone bio if we have a backing device Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 85/94] rv/dot2c: Make automaton definition static Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 86/94] iommu/vt-d: Allow NVS regions in arch_rmrr_sanity_check() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 87/94] iommu/vt-d: Clean up si_domain in the init_dmars() error path Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 88/94] wifi: mt76: mt7921e: fix random fw download fail Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 89/94] io_uring: dont gate task_work run on TIF_NOTIFY_SIGNAL Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 90/94] ext4: introduce EXT4_FC_TAG_BASE_LEN helper Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 91/94] ext4: factor out ext4_fc_get_tl() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 92/94] ext4: fix potential out of bound read in ext4_fc_replay_scan() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 93/94] [PATCH v3] ACPI: video: Force backlight native for more TongFang devices Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 6.0 94/94] mm: /proc/pid/smaps_rollup: fix no vmas null-deref Greg Kroah-Hartman
2022-10-27 17:11 ` [PATCH 6.0 00/94] 6.0.6-rc1 review Greg Kroah-Hartman
2022-10-27 18:22 ` Luna Jernberg
2022-10-27 18:46 ` Holger Hoffstätte
2022-10-27 21:13 ` Justin Forbes
2022-10-28  8:20 ` Bagas Sanjaya
2022-10-28  9:20 ` Naresh Kamboju
2022-10-28  9:25 ` Ron Economos
2022-10-28 10:18 ` Rudi Heitbaum
2022-10-28 10:35 ` Sudip Mukherjee (Codethink)
2022-10-28 11:59 ` Jon Hunter
2022-10-28 22:01 ` Florian Fainelli
2022-10-29  3:36 ` Guenter Roeck

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=20221027165057.802876819@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=graf@amazon.com \
    --cc=patches@lists.linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).