Commit 640a0c5e authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Avoid timeouts in mach_fuzzer::SendMessage()

Using mach_msg_send() will wait until the message is delivered. If the
receiver is on the same thread as the sender, then the kernel message
queue can fill up and block the sender indefinitely. Switch to using
mach_msg() with a 0-second timeout and return the error in that
scenario instead.

Bug: 950323
Change-Id: Ia9491034cca45239417f8954f80b1bfb1817e1b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731478Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683353}
parent a0301777
...@@ -159,7 +159,9 @@ SendResult SendMessage(mach_port_t remote_port, const MachMessage& proto) { ...@@ -159,7 +159,9 @@ SendResult SendMessage(mach_port_t remote_port, const MachMessage& proto) {
base::ScopedMachMsgDestroy scoped_message(result.message.header); base::ScopedMachMsgDestroy scoped_message(result.message.header);
result.kr = mach_msg_send(result.message.header); result.kr = mach_msg(result.message.header, MACH_SEND_MSG | MACH_SEND_TIMEOUT,
result.message.header->msgh_size, 0, MACH_PORT_NULL,
/*timeout=*/0, MACH_PORT_NULL);
if (result.kr == KERN_SUCCESS) { if (result.kr == KERN_SUCCESS) {
scoped_message.Disarm(); scoped_message.Disarm();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment