diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2024-09-16 23:07:30 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2024-09-16 23:07:30 -0700 |
commit | 97281be7bb92ca1c1c5f089b1242cf6e673688ee (patch) | |
tree | 862b27dfb6315020437a5c72daf675976bacece6 | |
parent | e2bb7e45db6a9820292b6b01ce0dcdfae65cca9b (diff) |
libvmon: Revert "libvmon: assume short positive reads found EOF"
This reverts commit 9f564cf8df6ef5fcba37082ba8013d6175955125.
Experimenting with smaller initial seq_file buffers in the kernel
has exposed this actually breaks, which contradicts my
expectations for proc files established back in the /proc/mdstat
racy incremental parsing corrupting the output days.
I'm seeing /proc/$pid/task/$pid/children spit out short reads
when the seq_file size is smaller than the amount of output.
Userspace's read() call can provide a large buffer, and if
seq_file's is smaller than the children output, it'll split the
children output instead of enlarging the seq_file buf to the
read() buffers bounds.
-rw-r--r-- | src/libvmon/vmon.c | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c index ec33b2d..a8e2121 100644 --- a/src/libvmon/vmon.c +++ b/src/libvmon/vmon.c @@ -145,12 +145,6 @@ static int load_contents_fd(vmon_t *vmon, vmon_char_array_t *array, int fd, vmon memcmpcpy(&array->array[total], vmon->buf, len, changed, changed_pos); total += len; - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) { - len = 0; - break; - } } /* if we read something or didn't encounter an error, store the new total */ @@ -356,10 +350,6 @@ static sample_ret_t proc_sample_stat(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_ goto _out; /* this saves us the EOF read syscall */ } } - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) - break; } _out: @@ -449,10 +439,6 @@ static int proc_follow_children(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_follo assert(0); } } - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) - break; } /* look for children which seem to no longer exist (found by stale generation numbers) and queue them for unmonitoring, flag this as a children change too */ @@ -815,10 +801,6 @@ static sample_ret_t proc_sample_vm(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_vm goto _out; /* this saves us the EOF read syscall */ } } - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) - break; } _out: @@ -876,10 +858,6 @@ static sample_ret_t proc_sample_io(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_io goto _out; /* this saves us the EOF read syscall */ } } - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) - break; } _out: @@ -943,10 +921,6 @@ static sample_ret_t sys_sample_stat(vmon_t *vmon, vmon_sys_stat_t **store) goto _out; /* this saves us the EOF read syscall */ } } - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) - break; } _out: @@ -997,10 +971,6 @@ static sample_ret_t sys_sample_vm(vmon_t *vmon, vmon_sys_vm_t **store) goto _out; /* this saves us the EOF read syscall */ } } - - /* assume short read found EOF */ - if (len < sizeof(vmon->buf)) - break; } _out: |