Repository navigation
0.17.0 --- an enumeration ends with its directory, a context has the stack it asks for, and input can arrive unaltered - #37
Merged
Conversation
kal_fs_list_begin opens a descriptor of its own for each enumeration, and only kal_fs_list_next released it, on reaching the end. kal_fs_close_dir closed the directory's descriptor and nothing else, so an enumeration abandoned part-way kept its descriptor and buffer until the program exited, although fs.h says that closing the directory that produced an iterator releases it. Keep the listings not yet read to the end on a list, with the directory each was begun on. kal_fs_close_dir ends that directory's listings before the descriptor is closed, and kal_fs_list_next takes a listing off the list when it reaches the end or fails. The close now frees the listing, so an iterator used after its directory is closed uses freed memory instead of going on with the directory. The test begins and abandons 64 enumerations and compares the number of open descriptors before and after. It fails without the change.
…ot free what another context is reading The listing an iterator names is found among the open ones rather than read through, so a closed directory (a released handle, clause 6.7) or a stale iterator is refused with kal_err_invalid. A listing another context is inside kal_fs_list_next with is marked by the close and released by that context on its way out, so the close does not free a buffer a getdents64 is writing into (clause 6.6). Two contexts reading one enumeration take turns.
…e is asked for, and kal_task_start_sized asks The stack was one anonymous mapping from kal_alloc with nothing beneath it, and the C library above cannot place a guard of its own. It is now mapped with a 256 KiB inaccessible guard below it, larger than the 69,008-byte frame measured in that library at -O0. The default is the host's, 8 MiB, which costs address space and not memory. kal_task_start_sized (openkal 0.16) gives at least the size asked for and never less than the default; above a C runtime the request is passed to it.
Read as set only where ISTRIP, INLCR, IGNCR and ICRNL are all clear; set, all four are cleared; clear, ICRNL is restored, which is what this kernel ordinarily applies. A position already at the requested value is not written.
The enumeration of a closed directory is refused and a close racing a read ends it safely; a pseudo terminal this test makes delivers the return key and Ctrl+J as two bytes once KAL_TERM_PASS_INPUT is set, and the kernel's ordinary rewriting when it is clear; a context started with a least stack size is told at least that size and has the room.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #34. Supersedes #35, whose commit is carried with its author.
kal_fs_list_nextrefuses a closed directory or an iterator that is not an open listing of the directory given, without reading through it (clause 6.7). A close that races a read of the same enumeration marks the listing and the reader releases it (clause 6.6).-O0.kal_task_start_sized(openkal 0.16) gives at least the size asked for and never less than the default.KAL_TERM_PASS_INPUTisISTRIP | INLCR | IGNCR | ICRNL: read as set only where all four are clear; set, all four are cleared; clear,ICRNLis restored.Observed in this package's tests: the leak through
/proc/self/fd, the refusals, two hundred close/read races; a pseudo terminal delivering the return key and Ctrl+J as 0x0d and 0x0a with the position set; a least stack size as room for 1, 16 and 64 MiB. The specification's suite atopenkal-0.16.0: 201 held, 0 did not hold.