Commit 77f20b46 authored by Kenton Varda's avatar Kenton Varda

Fix typos spotted by @a-robinson and update test failure messages to indicate…

Fix typos spotted by @a-robinson and update test failure messages to indicate that either testing failing could be due to OS SCM_RIGHTS truncation bug.
parent 16ac7b01
...@@ -990,7 +990,7 @@ struct CapDescriptor { ...@@ -990,7 +990,7 @@ struct CapDescriptor {
} }
attachedFd @6 :UInt8 = 0xff; attachedFd @6 :UInt8 = 0xff;
# If the RPC message in which this CapDescriptor was delivered also had file descirptors # If the RPC message in which this CapDescriptor was delivered also had file descriptors
# attached, and `fd` is a valid index into the list of attached file descriptors, then # attached, and `fd` is a valid index into the list of attached file descriptors, then
# that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds # that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds
# for said list, then no FD is attached. # for said list, then no FD is attached.
......
...@@ -327,7 +327,11 @@ TEST(AsyncIo, ScmRightsTruncatedOdd) { ...@@ -327,7 +327,11 @@ TEST(AsyncIo, ScmRightsTruncatedOdd) {
// Second pipe should have been closed implicitly because we didn't provide space to receive it. // Second pipe should have been closed implicitly because we didn't provide space to receive it.
KJ_NONBLOCKING_SYSCALL(n = read(in2, buffer, 4)); KJ_NONBLOCKING_SYSCALL(n = read(in2, buffer, 4));
if (n < 0) { if (n < 0) {
KJ_FAIL_ASSERT("out2 was not closed"); KJ_FAIL_ASSERT("out2 was not closed. This could indicate that your operating system kernel is "
"buggy and leaks file descriptors when an SCM_RIGHTS message is truncated. FreeBSD was "
"known to do this until late 2018, while MacOS still has this bug as of this writing in "
"2019. However, KJ works around the problem on those platforms. You need to enable the "
"same work-around for your OS -- search for 'SCM_RIGHTS' in src/kj/async-io-unix.c++.");
} }
KJ_ASSERT(n == 0); KJ_ASSERT(n == 0);
} }
...@@ -409,12 +413,11 @@ TEST(AsyncIo, ScmRightsTruncatedEven) { ...@@ -409,12 +413,11 @@ TEST(AsyncIo, ScmRightsTruncatedEven) {
// Third pipe should have been closed implicitly because we didn't provide space to receive it. // Third pipe should have been closed implicitly because we didn't provide space to receive it.
KJ_NONBLOCKING_SYSCALL(n = read(in3, buffer, 4)); KJ_NONBLOCKING_SYSCALL(n = read(in3, buffer, 4));
if (n < 0) { if (n < 0) {
KJ_FAIL_ASSERT("out3 was not closed. If ScmRightsTruncatedOdd passed but this test failed " KJ_FAIL_ASSERT("out3 was not closed. This could indicate that your operating system kernel is "
"then your operating system kernel is buggy and leakds file descriptors when an " "buggy and leaks file descriptors when an SCM_RIGHTS message is truncated. FreeBSD was "
"SCM_RIGHTS message is truncated. FreeBSD was known to do this until late 2018, while " "known to do this until late 2018, while MacOS still has this bug as of this writing in "
"MacOS still has this bug as of this writing in 2019. However, KJ works around the " "2019. However, KJ works around the problem on those platforms. You need to enable the "
"problem on those platforms. You need to enable the same work-around for your OS -- " "same work-around for your OS -- search for 'SCM_RIGHTS' in src/kj/async-io-unix.c++.");
"search for 'SCM_RIGHTS' in src/kj/async-io-unix.c++.");
} }
KJ_ASSERT(n == 0); KJ_ASSERT(n == 0);
} }
......
...@@ -195,12 +195,12 @@ public: ...@@ -195,12 +195,12 @@ public:
virtual Promise<ReadResult> tryReadWithFds(void* buffer, size_t minBytes, size_t maxBytes, virtual Promise<ReadResult> tryReadWithFds(void* buffer, size_t minBytes, size_t maxBytes,
AutoCloseFd* fdBuffer, size_t maxFds) = 0; AutoCloseFd* fdBuffer, size_t maxFds) = 0;
// Read data from the stream that may have file descriptors attached. Any attached descriptors // Read data from the stream that may have file descriptors attached. Any attached descriptors
// will be added to `fds`. If multiple bundles of FDs are encountered in the course of reading // will be placed in `fdBuffer`. If multiple bundles of FDs are encountered in the course of
// the amount of data requested by minBytes/maxBytes, then they will be concatenated. If more FDs // reading the amount of data requested by minBytes/maxBytes, then they will be concatenated. If
// are received than fit in the buffer, then the excess will be discarded and closed -- this // more FDs are received than fit in the buffer, then the excess will be discarded and closed --
// behavior, while ugly, is important to defend against denial-of-service attacks that may fill // this behavior, while ugly, is important to defend against denial-of-service attacks that may
// up the FD table with garbage. Applications must think carefully about how many FDs they really // fill up the FD table with garbage. Applications must think carefully about how many FDs they
// need to receive at once and set a well-defined limit. // really need to receive at once and set a well-defined limit.
virtual Promise<void> writeWithStreams(ArrayPtr<const byte> data, virtual Promise<void> writeWithStreams(ArrayPtr<const byte> data,
ArrayPtr<const ArrayPtr<const byte>> moreData, ArrayPtr<const ArrayPtr<const byte>> moreData,
......
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