Bug 102690 - add sanity check to avoid buffer overflow
Summary: add sanity check to avoid buffer overflow
Status: RESOLVED NOTABUG
Alias: None
Product: Wayland
Classification: Unclassified
Component: wayland (show other bugs)
Version: unspecified
Hardware: Other All
: medium critical
Assignee: Wayland bug list
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-13 03:10 UTC by Boram
Modified: 2018-06-04 06:58 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
patch file to fix issue (1.14 KB, patch)
2017-09-13 03:10 UTC, Boram
Details | Splinter Review

Description Boram 2017-09-13 03:10:50 UTC
Created attachment 134188 [details] [review]
patch file to fix issue

Before putting data into a buffer, we have to make sure that the data size is smaller than not only the buffer's full size but also the buffer's empty size.
Comment 1 Pekka Paalanen 2017-09-13 07:45:24 UTC
Hi,

thanks for the patch.

Patches should be sent to the wayland-devel@ mailing list as per the contribution instructions linked to from https://wayland.freedesktop.org/ .

I believe the check you are adding is redundant with the checks in the callers of wl_buffer_put(): wl_connection_write() and wl_connection_queue(). Both callers first check if the 'count' bytes fit in wl_buffer_size() and if not, they force a flush that either completely empties the buffer or fails and causes an early exit from the functions. Therefore the callers ensure that either the 'count' bytes fit, or the buffer is completely empty.

But I do agree that all that looks fragile.

Even if the check you add seems redundant, I think it would be good to have. A sanity check, as you say.

Please, re-send this patch to wayland-devel@ mailing list with a link to this bug report and the following line:

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>

added to the commit message.
Comment 2 Boram 2017-09-15 00:22:37 UTC
Hi

thanks for your comment. I've sent my patch to wayland-devel mailing.
Comment 3 Daniel Stone 2018-06-04 06:58:31 UTC
Patch was discussed on the list; closing this bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.