Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1643869pxy; Mon, 2 Aug 2021 06:58:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdXGI1a+G2t5+HN6PZuPpTdj1/GZme6iPGGTY1Ra2qeplxFp9mMNPORmHeaYl75OJqDNeY X-Received: by 2002:a05:6402:cb9:: with SMTP id cn25mr19783201edb.271.1627912718647; Mon, 02 Aug 2021 06:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912718; cv=none; d=google.com; s=arc-20160816; b=B04Qnjuml5qZLbWeMCDu/1vIKdzCLVAdBT+4nfekff4bk0GVuonExs8gCQmOWmjWlj kZIWtYmThQddCZUnVaF+pty1v6GSnYCaoGHqb7O7XO6/ssrpy7U6WGzXZulh7nq3ivdT /ueoXCeHOT6Vn9m8mGxrE7ymFo2rFThxkmDHOjqmHs5cPw+7576jpPLuEqM0uwFufYWe vKjrxFzGkkFjg/O1nJsONofQxppyWWIuatShEyfqXJ0srOJRA/+y8g2+SRXlHEa0G4wz bqcrqENZx63JNmJdQlpj9BDqV3VUmHTWRcfO1JAc73GdcJO+Wc6wB36O2OgfZefJxkr+ lE2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WkdvjyZPxDUSg4QKGhWIHIQ1K2BG8LbK8AEXCRb0ftc=; b=pkChQiGmnm4dysxQdJKiy6o0IafwSXSUgjpexmKHpKZhpObQbhwpUN6f5ujZ71f2eI mc6VcqYtgea9ay5rYqmMW5mHBJzCpf1nIobMOpwcXkuVwX1YNsDkmMX4yeViJ1Uh3OZ1 epwMoEAj/adTFSVKCP0qtSh7h+9HnzMBrsT2HJM/vfEASGOH4wEIvT4xT7wHWvS7t4M9 vVpIhRLWmg6n0AYAPozEkqnCky/RP8ooSjWtrwQqsYmCQadRogT9/+0LzMV/K6UEsuwP eUHeuUcHiqp29We5Q+aX0dcwycPQCIpy+oxnDa8J5iUMOOu6m4WwGKzQy4NgAsqCd19m vkYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T5d+ROhL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si10951990edh.361.2021.08.02.06.58.15; Mon, 02 Aug 2021 06:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T5d+ROhL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234694AbhHBN5I (ORCPT + 99 others); Mon, 2 Aug 2021 09:57:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234202AbhHBNvN (ORCPT ); Mon, 2 Aug 2021 09:51:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7382A60F6D; Mon, 2 Aug 2021 13:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912249; bh=9o16gPzS/KDaIxvlKZ6tdpwutcU0Jo6AZP1S3JwO9Eo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5d+ROhLF2LiwnwdOUDaalIt529ESV3P6t+ldu7XG78PwTjM8ARN6d7zCRFF/rMK6 6cf+cn3TMamPCJVwqr351RD3dC7V9gMNcj4eQntRlSwwvxN7/0iuuW7Uw/cPsRDjCY AtcRSstZ15dF40grsK1hgCmmLWl57c9t7ITAAvXQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Xu , Paolo Bonzini Subject: [PATCH 5.4 07/40] KVM: add missing compat KVM_CLEAR_DIRTY_LOG Date: Mon, 2 Aug 2021 15:44:47 +0200 Message-Id: <20210802134335.634793928@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134335.408294521@linuxfoundation.org> References: <20210802134335.408294521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Bonzini commit 8750f9bbda115f3f79bfe43be85551ee5e12b6ff upstream. The arguments to the KVM_CLEAR_DIRTY_LOG ioctl include a pointer, therefore it needs a compat ioctl implementation. Otherwise, 32-bit userspace fails to invoke it on 64-bit kernels; for x86 it might work fine by chance if the padding is zero, but not on big-endian architectures. Reported-by: Thomas Sattler Cc: stable@vger.kernel.org Fixes: 2a31b9db1535 ("kvm: introduce manual dirty log reprotect") Reviewed-by: Peter Xu Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/kvm_main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3570,6 +3570,16 @@ struct compat_kvm_dirty_log { }; }; +struct compat_kvm_clear_dirty_log { + __u32 slot; + __u32 num_pages; + __u64 first_page; + union { + compat_uptr_t dirty_bitmap; /* one bit per page */ + __u64 padding2; + }; +}; + static long kvm_vm_compat_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { @@ -3579,6 +3589,24 @@ static long kvm_vm_compat_ioctl(struct f if (kvm->mm != current->mm) return -EIO; switch (ioctl) { +#ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT + case KVM_CLEAR_DIRTY_LOG: { + struct compat_kvm_clear_dirty_log compat_log; + struct kvm_clear_dirty_log log; + + if (copy_from_user(&compat_log, (void __user *)arg, + sizeof(compat_log))) + return -EFAULT; + log.slot = compat_log.slot; + log.num_pages = compat_log.num_pages; + log.first_page = compat_log.first_page; + log.padding2 = compat_log.padding2; + log.dirty_bitmap = compat_ptr(compat_log.dirty_bitmap); + + r = kvm_vm_ioctl_clear_dirty_log(kvm, &log); + break; + } +#endif case KVM_GET_DIRTY_LOG: { struct compat_kvm_dirty_log compat_log; struct kvm_dirty_log log;