Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311654 > unrolled thread

[PATCH] xen: fix potential integer overflow in queue_reply

Started byInsu Yun <wuninsu@gmail.com>
First post2016-01-18 17:30 +0100
Last post2016-01-18 17:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] xen: fix potential integer overflow in queue_reply Insu Yun <wuninsu@gmail.com> - 2016-01-18 17:30 +0100
    Re: [PATCH] xen: fix potential integer overflow in queue_reply David Vrabel <david.vrabel@citrix.com> - 2016-01-18 17:40 +0100
      Re: [Xen-devel] [PATCH] xen: fix potential integer overflow in queue_reply David Vrabel <david.vrabel@citrix.com> - 2016-01-18 17:50 +0100

#1311654 — [PATCH] xen: fix potential integer overflow in queue_reply

FromInsu Yun <wuninsu@gmail.com>
Date2016-01-18 17:30 +0100
Subject[PATCH] xen: fix potential integer overflow in queue_reply
Message-ID<qSkQO-38H-1@gated-at.bofh.it>
When len is greater than UINT_MAX - sizeof(*rb), in next allocation,
it can overflow integer range and allocates small size of heap.
After that, memcpy will overflow the allocated heap.
Therefore, it needs to check the size of given length.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/xen/xenbus/xenbus_dev_frontend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 9433e46..b45ed69 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -186,7 +186,7 @@ static int queue_reply(struct list_head *queue, const void *data, size_t len)
 {
 	struct read_buffer *rb;
 
-	if (len == 0)
+	if (len == 0 || len >= UINT_MAX - sizeof(*rb))
 		return 0;
 
 	rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
-- 
1.9.1

[toc] | [next] | [standalone]


#1311660

FromDavid Vrabel <david.vrabel@citrix.com>
Date2016-01-18 17:40 +0100
Message-ID<qSl0t-3eo-3@gated-at.bofh.it>
In reply to#1311654
On 18/01/16 16:29, Insu Yun wrote:
> When len is greater than UINT_MAX - sizeof(*rb), in next allocation,
> it can overflow integer range and allocates small size of heap.
> After that, memcpy will overflow the allocated heap.
> Therefore, it needs to check the size of given length.
[...]
> --- a/drivers/xen/xenbus/xenbus_dev_frontend.c
> +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
> @@ -186,7 +186,7 @@ static int queue_reply(struct list_head *queue, const void *data, size_t len)
>  {
>  	struct read_buffer *rb;
>  
> -	if (len == 0)
> +	if (len == 0 || len >= UINT_MAX - sizeof(*rb))
                               ^^^^^^^^^^^^^^^^^^^^^^
Please check

    len > XENSTORE_PAYLOAD_MAX

instead.

David

[toc] | [prev] | [next] | [standalone]


#1311670 — Re: [Xen-devel] [PATCH] xen: fix potential integer overflow in queue_reply

FromDavid Vrabel <david.vrabel@citrix.com>
Date2016-01-18 17:50 +0100
SubjectRe: [Xen-devel] [PATCH] xen: fix potential integer overflow in queue_reply
Message-ID<qSlaa-3jC-19@gated-at.bofh.it>
In reply to#1311660
On 18/01/16 16:38, David Vrabel wrote:
> On 18/01/16 16:29, Insu Yun wrote:
>> When len is greater than UINT_MAX - sizeof(*rb), in next allocation,
>> it can overflow integer range and allocates small size of heap.
>> After that, memcpy will overflow the allocated heap.
>> Therefore, it needs to check the size of given length.
> [...]
>> --- a/drivers/xen/xenbus/xenbus_dev_frontend.c
>> +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
>> @@ -186,7 +186,7 @@ static int queue_reply(struct list_head *queue, const void *data, size_t len)
>>  {
>>  	struct read_buffer *rb;
>>  
>> -	if (len == 0)
>> +	if (len == 0 || len >= UINT_MAX - sizeof(*rb))
>                                ^^^^^^^^^^^^^^^^^^^^^^
> Please check
> 
>     len > XENSTORE_PAYLOAD_MAX
> 
> instead.

And return -EINVAL in this case (not zero).

David

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web