gramineproject / graphene

Graphene / Graphene-SGX - a library OS for Linux multi-process applications, with Intel SGX support
https://grapheneproject.io
GNU Lesser General Public License v3.0
769 stars 260 forks source link

[LibOS] Return a partial write in `do_sendmsg` if host-level write was partial #2679

Closed jkr0103 closed 3 years ago

jkr0103 commented 3 years ago

Signed-off-by: Jitender Kumar jitender.kumar@intel.com

Description of the changes

Previously, do_sendmsg iterated through all iovec buffers supplied by the user, regardless of whether the host-level write to the socket (via DkStreamWrite) was able to send the whole buffer or only part of the buffer.

This could lead to data corruptions: Graphene would send only some parts of the buffers (i.e., with gaps) but would report to the user app the total sum of sent bytes (i.e., without gaps).

This PR fixes this by simply bailing out on the first encountered host-level partial write.

Fixes #2664

How to test this PR?

Create a communication channel between client and server and send large size data for example 4194299 bytes multiple times.


This change is Reviewable

dimakuv commented 3 years ago

Jenkins, test this please

dimakuv commented 3 years ago

Jenkins, test this please