Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1646710pxy; Mon, 2 Aug 2021 07:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRbwyvDCjFcUl1vN/wWfQleAcr7sl6rhIgpawrRRlmzyGD4AglKN9xuMXqAfNylnNZReEj X-Received: by 2002:a17:906:c08e:: with SMTP id f14mr15459397ejz.380.1627912911506; Mon, 02 Aug 2021 07:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912911; cv=none; d=google.com; s=arc-20160816; b=xEmzF+H7czOAjunLzue5jNQu2AqaKJVly7hZhfH4ujqlkMdAhKQcuNdujtq/mYc9eH yut0uwkkBouis6JFrf5oj0o00QJ3ch/artCLMZ7I9qciqKJayvOGaaoqREri/cTjRgs7 wIsby00gtpu7cy8lCjjsaBRywAEPN3uwD8Fa7XZU8gZyrI7tHnfiycaQ28Gg+UHC5rVd GpKKPTQgU9kwnogbLETXdgmu87EpJ5rfdvmlPjJhTIH8IFjsb8Vd5x4VaQXDzHilN1gz Q+oF1xY9hRGt/oUD07PzhfTRVwhzo72GNogRHe8xbrxdhofdDBl6e8btcr3QaoQt3eXM vF9w== 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=ipXFYbRlwP40gm/UoCqjthKKs7+yEdHsgsN6Vuc9oyA=; b=CdaQddBlskNkyJyZuaQYTpZP/M6vtyNfw8IgPaUNAX8O0EKNyFIWFwZDD485r2N67u 8/BWnMFPi7KpgH4PRSUQ99ZZ4ibUnyft+xeI0be7y0eyMBynoK2Z2y1OydZZYAIgdXOC 9nRFT77B9ZRfx5GUL51agHeQ8qd0Nxb6LdBTfjFpB/4RPE/ZuYpXs0+N7MhERZS8BC9B yK5D1qPvt73yAvZV2IoBitE2rI0IzuI+ymuWx7iGaQZQLutEXCA86G8OADOvlh++9gaI wxQXIWLpfKunRa8qEKs3wz9xqqyc+9xXDIGWQKTim3hKiM4akCWYIHdEYhPwQjRtFi9t wXvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DmHwLBeS; 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 r24si11935054ejy.194.2021.08.02.07.01.26; Mon, 02 Aug 2021 07:01:51 -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=DmHwLBeS; 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 S236612AbhHBN7q (ORCPT + 99 others); Mon, 2 Aug 2021 09:59:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:33536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235775AbhHBNy0 (ORCPT ); Mon, 2 Aug 2021 09:54:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B183260F41; Mon, 2 Aug 2021 13:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912365; bh=voG3CVZomaCHcJwbP4BJ0FYFj/FXmFV8kOSaUwIg700=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DmHwLBeSUFOkC7jfuBCy0K3ljsfhCKvIgVnibFC6fzYvxSpo5odpr9UTtjd+CyE0J V9xbhaFJnR5zDILgWBL9QF4/O+c4VcoONdq1db3LRtTgkYT7q0frkJuyMYSpnTxbA/ 1As9KndGO3fTiCf/EQvkv7iex2IYsOakrv5rS10Y= 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.10 09/67] KVM: add missing compat KVM_CLEAR_DIRTY_LOG Date: Mon, 2 Aug 2021 15:44:32 +0200 Message-Id: <20210802134339.333434436@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@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 @@ -3896,6 +3896,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) { @@ -3905,6 +3915,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;