linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] kvm: svm: fix potential get_num_contig_pages overflow
@ 2019-03-19 22:19 David Rientjes
  2019-03-20 14:07 ` Singh, Brijesh
  2019-04-05 18:49 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: David Rientjes @ 2019-03-19 22:19 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, Joerg Roedel
  Cc: Cfir Cohen, Brijesh Singh, Tom Lendacky, x86, kvm, linux-kernel

get_num_contig_pages() could potentially overflow int so make its type 
consistent with its usage.

Reported-by: Cfir Cohen <cfir@google.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 arch/x86/kvm/svm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6422,11 +6422,11 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
 	return ret;
 }
 
-static int get_num_contig_pages(int idx, struct page **inpages,
-				unsigned long npages)
+static unsigned long get_num_contig_pages(unsigned long idx,
+				struct page **inpages, unsigned long npages)
 {
 	unsigned long paddr, next_paddr;
-	int i = idx + 1, pages = 1;
+	unsigned long i = idx + 1, pages = 1;
 
 	/* find the number of contiguous pages starting from idx */
 	paddr = __sme_page_pa(inpages[idx]);
@@ -6445,12 +6445,12 @@ static int get_num_contig_pages(int idx, struct page **inpages,
 
 static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
 {
-	unsigned long vaddr, vaddr_end, next_vaddr, npages, size;
+	unsigned long vaddr, vaddr_end, next_vaddr, npages, pages, size, i;
 	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
 	struct kvm_sev_launch_update_data params;
 	struct sev_data_launch_update_data *data;
 	struct page **inpages;
-	int i, ret, pages;
+	int ret;
 
 	if (!sev_guest(kvm))
 		return -ENOTTY;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] kvm: svm: fix potential get_num_contig_pages overflow
  2019-03-19 22:19 [patch] kvm: svm: fix potential get_num_contig_pages overflow David Rientjes
@ 2019-03-20 14:07 ` Singh, Brijesh
  2019-04-04 20:55   ` David Rientjes
  2019-04-05 18:49 ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Singh, Brijesh @ 2019-03-20 14:07 UTC (permalink / raw)
  To: David Rientjes, Paolo Bonzini, Radim Krčmář, Joerg Roedel
  Cc: Singh, Brijesh, Cfir Cohen, Lendacky, Thomas, x86, kvm, linux-kernel



On 3/19/19 5:19 PM, David Rientjes wrote:
> get_num_contig_pages() could potentially overflow int so make its type
> consistent with its usage.
> 
> Reported-by: Cfir Cohen <cfir@google.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>   arch/x86/kvm/svm.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 

Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] kvm: svm: fix potential get_num_contig_pages overflow
  2019-03-20 14:07 ` Singh, Brijesh
@ 2019-04-04 20:55   ` David Rientjes
  0 siblings, 0 replies; 4+ messages in thread
From: David Rientjes @ 2019-04-04 20:55 UTC (permalink / raw)
  To: Singh, Brijesh, Paolo Bonzini, Radim Krčmář
  Cc: Joerg Roedel, Cfir Cohen, Lendacky, Thomas, x86, kvm, linux-kernel

On Wed, 20 Mar 2019, Singh, Brijesh wrote:

> > get_num_contig_pages() could potentially overflow int so make its type
> > consistent with its usage.
> > 
> > Reported-by: Cfir Cohen <cfir@google.com>
> > Signed-off-by: David Rientjes <rientjes@google.com>
> > ---
> >   arch/x86/kvm/svm.c | 10 +++++-----
> >   1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> 
> Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
> 

Paolo, Radim, I don't see this in kvm.git, is it ready to be staged?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] kvm: svm: fix potential get_num_contig_pages overflow
  2019-03-19 22:19 [patch] kvm: svm: fix potential get_num_contig_pages overflow David Rientjes
  2019-03-20 14:07 ` Singh, Brijesh
@ 2019-04-05 18:49 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2019-04-05 18:49 UTC (permalink / raw)
  To: David Rientjes, Radim Krčmář, Joerg Roedel
  Cc: Cfir Cohen, Brijesh Singh, Tom Lendacky, x86, kvm, linux-kernel

On 19/03/19 23:19, David Rientjes wrote:
> get_num_contig_pages() could potentially overflow int so make its type 
> consistent with its usage.
> 
> Reported-by: Cfir Cohen <cfir@google.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  arch/x86/kvm/svm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -6422,11 +6422,11 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  	return ret;
>  }
>  
> -static int get_num_contig_pages(int idx, struct page **inpages,
> -				unsigned long npages)
> +static unsigned long get_num_contig_pages(unsigned long idx,
> +				struct page **inpages, unsigned long npages)
>  {
>  	unsigned long paddr, next_paddr;
> -	int i = idx + 1, pages = 1;
> +	unsigned long i = idx + 1, pages = 1;
>  
>  	/* find the number of contiguous pages starting from idx */
>  	paddr = __sme_page_pa(inpages[idx]);
> @@ -6445,12 +6445,12 @@ static int get_num_contig_pages(int idx, struct page **inpages,
>  
>  static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  {
> -	unsigned long vaddr, vaddr_end, next_vaddr, npages, size;
> +	unsigned long vaddr, vaddr_end, next_vaddr, npages, pages, size, i;
>  	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
>  	struct kvm_sev_launch_update_data params;
>  	struct sev_data_launch_update_data *data;
>  	struct page **inpages;
> -	int i, ret, pages;
> +	int ret;
>  
>  	if (!sev_guest(kvm))
>  		return -ENOTTY;
> 

I had missed it, and now I've queued it.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-05 18:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 22:19 [patch] kvm: svm: fix potential get_num_contig_pages overflow David Rientjes
2019-03-20 14:07 ` Singh, Brijesh
2019-04-04 20:55   ` David Rientjes
2019-04-05 18:49 ` Paolo Bonzini

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).