[v2] drivers/misc/vmw_vmci: restrict too big queue size in
diff mbox series

Message ID 20210209093101.2097627-1-snovitoll@gmail.com
State New, archived
Headers show
Series
  • [v2] drivers/misc/vmw_vmci: restrict too big queue size in
Related show

Commit Message

Sabyrzhan Tasbolatov Feb. 9, 2021, 9:31 a.m. UTC
syzbot found WARNING in qp_broker_alloc[1] in qp_host_alloc_queue()
when num_pages is 0x100001, giving queue_size + queue_page_size
bigger than KMALLOC_MAX_SIZE for kzalloc(), resulting order >= MAX_ORDER
condition.

queue_size + queue_page_size=0x8000d8, where KMALLOC_MAX_SIZE=0x400000.

Reported-by: syzbot+15ec7391f3d6a1a7cc7d@syzkaller.appspotmail.com
Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
---
>As this is controllable by userspace, you just provided a way to flood
>the kernel logs.
>
>Please make this a dev_dbg() call instead, if you really want to see it.
>Otherwise just return NULL, no need to report anything, right?

Thanks, removed pr_warn().

v2: Removed pr_warn() to avoid flood from user-space
---
 drivers/misc/vmw_vmci/vmci_queue_pair.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Alex Dewar Feb. 9, 2021, 9:32 a.m. UTC | #1
On 09/02/2021 09:31, Sabyrzhan Tasbolatov wrote:
> syzbot found WARNING in qp_broker_alloc[1] in qp_host_alloc_queue()
> when num_pages is 0x100001, giving queue_size + queue_page_size
> bigger than KMALLOC_MAX_SIZE for kzalloc(), resulting order >= MAX_ORDER
> condition.
>
> queue_size + queue_page_size=0x8000d8, where KMALLOC_MAX_SIZE=0x400000.
>
> Reported-by: syzbot+15ec7391f3d6a1a7cc7d@syzkaller.appspotmail.com
> Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
> ---
>> As this is controllable by userspace, you just provided a way to flood
>> the kernel logs.
>>
>> Please make this a dev_dbg() call instead, if you really want to see it.
>> Otherwise just return NULL, no need to report anything, right?
> Thanks, removed pr_warn().
Looks like you forgot to take out the opening brace.

>
> v2: Removed pr_warn() to avoid flood from user-space
> ---
>   drivers/misc/vmw_vmci/vmci_queue_pair.c | 2 --
>   1 file changed, 2 deletions(-)
>
> diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> index f6af406fda80..ea16df73cde0 100644
> --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
> +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> @@ -538,9 +538,7 @@ static struct vmci_queue *qp_host_alloc_queue(u64 size)
>   	queue_page_size = num_pages * sizeof(*queue->kernel_if->u.h.page);
>   
>   	if (queue_size + queue_page_size > KMALLOC_MAX_SIZE) {
> -		pr_warn("too big queue to allocate\n");
>   		return NULL;
> -	}
>   
>   	queue = kzalloc(queue_size + queue_page_size, GFP_KERNEL);
>   	if (queue) {
Greg Kroah-Hartman Feb. 9, 2021, 9:49 a.m. UTC | #2
On Tue, Feb 09, 2021 at 03:31:01PM +0600, Sabyrzhan Tasbolatov wrote:
> syzbot found WARNING in qp_broker_alloc[1] in qp_host_alloc_queue()
> when num_pages is 0x100001, giving queue_size + queue_page_size
> bigger than KMALLOC_MAX_SIZE for kzalloc(), resulting order >= MAX_ORDER
> condition.
> 
> queue_size + queue_page_size=0x8000d8, where KMALLOC_MAX_SIZE=0x400000.
> 
> Reported-by: syzbot+15ec7391f3d6a1a7cc7d@syzkaller.appspotmail.com
> Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
> ---
> >As this is controllable by userspace, you just provided a way to flood
> >the kernel logs.
> >
> >Please make this a dev_dbg() call instead, if you really want to see it.
> >Otherwise just return NULL, no need to report anything, right?
> 
> Thanks, removed pr_warn().
> 
> v2: Removed pr_warn() to avoid flood from user-space
> ---
>  drivers/misc/vmw_vmci/vmci_queue_pair.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> index f6af406fda80..ea16df73cde0 100644
> --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
> +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> @@ -538,9 +538,7 @@ static struct vmci_queue *qp_host_alloc_queue(u64 size)
>  	queue_page_size = num_pages * sizeof(*queue->kernel_if->u.h.page);
>  
>  	if (queue_size + queue_page_size > KMALLOC_MAX_SIZE) {
> -		pr_warn("too big queue to allocate\n");
>  		return NULL;
> -	}
>  

This patch doesn't apply to the tree, you can't send me a patch that is
relative to your previous one, that doesn't work at all.

And also, test-build your patches always first, to not do so is a bit
rude to maintainers...

thanks,

greg k-h

Patch
diff mbox series

diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
index f6af406fda80..ea16df73cde0 100644
--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
+++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
@@ -538,9 +538,7 @@  static struct vmci_queue *qp_host_alloc_queue(u64 size)
 	queue_page_size = num_pages * sizeof(*queue->kernel_if->u.h.page);
 
 	if (queue_size + queue_page_size > KMALLOC_MAX_SIZE) {
-		pr_warn("too big queue to allocate\n");
 		return NULL;
-	}
 
 	queue = kzalloc(queue_size + queue_page_size, GFP_KERNEL);
 	if (queue) {